How to pass parameters to DbSet.SqlQuery Method in Entity Framework

前端 未结 2 956
予麋鹿
予麋鹿 2021-02-05 09:19

I am trying to execute a RAW SQL statement in Entity Framework which takes some parameters. The method I am using is from DbSet.SqlQuery

I am confused on how to construc

2条回答
  •  孤城傲影
    2021-02-05 09:56

    The above answers are correct but since the signature for SqlQuery is SqlQuery(sql:String, params object[] parameters), you can simplify the code and give it a more natural feel by using:

    context.SqlQuery(sql, latParam, lngPara);
    

    This would be perfectly legal without having to array it first.

提交回复
热议问题