C# Data Access Layer (Not EF but SP and objects)

659 Views Asked by At

I have ben requested to create an application that uses an existing DB with stored procedures (insert, update, delete) and they don't want to use Entity Framework.

One way is to create my own Data Access Layer using System.Data.DataSet but I would like to know if there is any existing library or something I can use where I can fill objects from SP's and also update data using SP's.

Any clue?

3

There are 3 best solutions below

3
On BEST ANSWER

You can use a micro-orm like Dapper which is simple, efficient and maps correctly to objects.

Example of use :

// Call spGetUser with a parameter Id and put the result in a User instance.  
var user = cnn.Query<User>("spGetUser", new {Id = 1}, 
        commandType: CommandType.StoredProcedure).SingleOrDefault();
0
On

If you really want to go down this path, you can use Automapper

Take a look at this post How do I use automapper to map a dataset with multiple tables

Still, keep in mind that performance can actually be really bad.

IMHO, EF would be a better choice.

2
On

I usually recommend to use Dapper. it is very light-weight, it's performance is on par with ADO.NET coding.