This article shows how to use PostgreSQL with ASP.NET Core 1.0 using Dapper ORM. We will implement CRUD (Create, Read, Update and Delete) operations in ASP.NET MVC step by step.
Category: Architecture
Generalize a method to read any master table with C# and Dapper
On a web page or application form, it is common to have different master data like Country, State…etc. available in dropdownlist, listbox or any other control. It is needed to read all master data from database and bind to proper controls. This post explains different ways to read master tables with C# and Dapper.
A Better Way To Manage ASP.NET Session With Generic Wrapper
Before we get started, let us see the general way to use Session in ASP.NET
if (Session["UserName"] == null) { LabelUserName.Text = "Anonymous"; } else { LabelUserName.Text = (string)Session["UserName"]; }
You can feel some drawbacks e.g. to check null reference, type safety, to cast object..etc.
Now add following class and see how it solves the issues:
N-Layered App with Entity Framework, Autofac, ASP.NET MVC and Unit Testing
In my recent post, I explained how to implement a decoupled, unit-testable, N tier architecture based on Generic Repository Pattern with Entity Framework, IoC Container and Dependency Injection in ASP.NET MVC, then I got feedback against the repository/Unit of Work pattern. On googling, I found some more posts:
Say No to the Repository Pattern in your DAL
Repositories On Top UnitOfWork Are Not a Good Idea
Why Entity Framework renders the Repository pattern obsolete?
Entity Framework already implements a repository pattern. Implementing another layer on top of this is not only redundant, but makes maintenance harder. You might want to mock your Entity Framework context rather than using the repository pattern. This post explains how you can implement N Layered app without repository/unit of work pattern on top of EF.
Generic Repository and Unit of Work Pattern, Entity Framework, Unit Testing, Autofac IoC Container and ASP.NET MVC [Part 4]
This is the summary post of the series. I would recommend you to read following posts first:
1. Implementing Generic Repository and Unit of Work Pattern With Entity Framework
2. Dependency Injection in ASP.NET MVC using Autofac and CRUD operations
Generic Repository and Unit of Work Pattern, Entity Framework, Unit Testing, Autofac IoC Container and ASP.NET MVC [Part 3]
In my last two posts, We have done following things:
Implementing Generic Repository and Unit of Work Pattern With Entity Framework
Dependency Injection in ASP.NET MVC using Autofac and CRUD operations
In this post, we are going to start writing our unit test.
Generic Repository and Unit of Work Pattern, Entity Framework, Unit Testing, Autofac IoC Container and ASP.NET MVC [Part 2]
In my previous post, I created models, repository and service layer. Now we will implement CRUD operations using these layers and setup Autofac IoC Container.
I would recommend you to read previous post first if you have not read.
Generic Repository and Unit of Work Pattern, Entity Framework, Unit Testing, Autofac IoC Container and ASP.NET MVC [Part 1]
In this post, we will see how to implement a decoupled, unit-testable, N tier architecture based on Generic Repository Pattern with Entity Framework, IoC Container and Dependency Injection in ASP.NET MVC. We will implement a sample application step by step for the same.