Dynamic LINQ query to get Field value from Database

前端 未结 4 1292
耶瑟儿~
耶瑟儿~ 2021-01-18 03:20

is it possible?

Public String Get_Filed_By_Id(string table_Name,String Field_Name,string PK_val)
{
    string strRes=\"\";
    using(mydbcontext db=new mydbc         


        
4条回答
  •  情书的邮戳
    2021-01-18 03:58

    It is not really possible with EntityFramework actually(as far as I know). If you only needed the field by its name, then you could have used @Den's proposed solution. But you want to specify the table name too as a parameter. So I suggest you to use standard Sql Connector api, and build the query string with the parameters you provide.

    Check this link for usage of standard sql connector api.

提交回复
热议问题