C# Unit test a Repository class using a Seeded InMemoryDatabase
If you wanted to unit test a Repository that uses a DbContext with seeded data, you can use the InMemoryDatabase.
If you wanted to unit test a Repository that uses a DbContext with seeded data, you can use the InMemoryDatabase.
Unit testing Basic Authentication Handler in asp.net core (C# ), I will be using the Xunit (my preferred) and Moq, I personally prefer NSubstitute, but the project was already using Moq and I didn’t want to change it.
All the OData endpoints have stranded responses, I don’t want to change it. Now I need to do my Angular implementation to support OData stranded.
Recently I started playing around with Odata and wanted to fast track development with an existing database. I don’t want to waste time on data and the database structure, rather I spend time on asp.net core oData.
When you use AutoMapper to map our objects, and AutoMapper profiles are the way we do it, it encapsulates a lot of business logic in some cases. But we need to make sure the business logic gets unit tested.
As part of my Mediator handler, I have multiple dependencies injected they are DbContext, IMapper. But remember, as part of the application initialisation we have AutoMapper Profile registration automatically. But it’s not the case with Unit Testing we need to register the dependencies or mock them. Therefore we need to add the Profile to our IMapper initialisation.
Most of the apps we write have some data that not get updated frequently or not get updated at all. For example – suburb list, user roles, etc. We can avoid reading the database for all those entities by using a cached collection.
I had to create a chart from Chart JS to display, displaying data with Chart JS is super easy, but getting the data from the server is bit tricky unless you are a SQL expert (well not me :)). Below query will group it by month.
Registering the DbContext in order to use it throughout the application as ServiceLifetime.Transient
In this tutorial I will be building a Australian suburb look up module using ASP.NET Core web API, as the second part I will create the client side, using Angular 2
In this tutorial I will be building a Australian suburb look up module using ASP.NET Core web API, as the first part I will create the server side.
Using Sqlite in your asp.net core application
Pagination on server side is a very common scenario. So thought about creating helper.
You can refer to full list of commands here. Documenting this for my own reference especially as my mind goes blank sometimes
Auditing every changed field using the EntityFramework-Plus
Overriding Entity Framework SaveChanges() method so you can populate the entity ModifiedBy,ModifiedOn, CreatedBy, CreatedOn properties
Writing an extension for removing pluralisation of table names in Entity Framework Core extensions.
You will have to change the way the properties get mapped most of the time, as it not always one-to-one.
Since Entity Framework Core is fairly new (at the time I am writing) and still under development. Not most of the required features are not there out of the box and you will have to write extensions. I have to utilise an existing stored procedure to get some data from database. I have to use ADO […]
Entity Framework Core setting default database schema for your code first tables and migration history tables
Migrations and Seeding on ASP.NET Core