Is there a way to access the columns in a Dapper FastExpando via string or index?

后端 未结 3 625
[愿得一人]
[愿得一人] 2020-12-29 04:36

I am pulling in a Dapper FastExpando object and want to be able to reference the column names dynamically at run time rather than at design/compile time. So I

3条回答
  •  轮回少年
    2020-12-29 05:11

    There a simple way to access fields direct below sample

    string strConexao = WebConfigurationManager.ConnectionStrings["connection"].ConnectionString;
    
    conexaoBD = new SqlConnection(strConexao);
    conexaoBD.Open();
    
    var result = conexaoBD.Query("Select Field1,Field2 from Table").First();
    
    //access field value result.Field1 
    //access field value result.Field2
    
    if (result.Field1 == "abc"){ dosomething}
    

提交回复
热议问题