Entity Framework Core 2.1 - Generic Model in FromSql method

entity-framework-core entity-framework-core-2.1

Question

I have been using the below approach to call stored procedure in EF core 2.1

In DBContext

public DbQuery<SomeModel> SomeModels { get; set; }

Class

var result = context.SomeModels.FromSql("SQL_SCRIPT").ToList();

I'm trying to create a generic method to execute all stored procedures so that I don't need to physically attach a model with context each time when I call a stored procedure. I'm looking for something like what I have below (Ignore the syntax). Please advice.

public Response SoftDelete<T>(T entity) where T : class
{
    var result = context.<T>.FromSql("SQL_SCRIPT").ToList();
}
0
0
8/14/2018 2:24:34 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow