Search code examples
c#data-layer

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


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?


Solution

  • 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();