How to call a stored procedure in EF Core 3.0 via FromSqlRaw

后端 未结 6 1150
失恋的感觉
失恋的感觉 2020-12-03 14:04

I recently migrated from EF Core 2.2 to EF Core 3.0.

Unfortunately, I haven\'t found a way to call a stored procedure that returns an entity.

In EF Core 2.

6条回答
  •  天涯浪人
    2020-12-03 14:54

    var result=context.yourmodelclass.FromSqlInterpolated($"StoredProcedureName {param1},{param2}").tolist();
    

    You can add multiple parameters if needed. Note:

    • context => your name of database.
    • yourmodelclass => the class in models folder you create for fetching the output result from the stored procedure result.

提交回复
热议问题