Dapper: How to get value from DapperRow if column name is “count(*)”?

后端 未结 2 627
感动是毒
感动是毒 2021-02-13 05:27

I have a dynamic result from Dapper query that contains records like this:

{DapperRow, billing_currency_code = \'USD\', count(*) = \'6\'}

I\'m

2条回答
  •  情书的邮戳
    2021-02-13 05:58

    Suppose Your Data as below

    var Details={DapperRow, billing_currency_code = 'USD', count(*) = '6'}
    

    as The columns is coming dynamically

    var firstRow= Details.FirstOrDefault();
    

    To get the heading columns of the data

    var Heading= ((IDictionary)firstRow).Keys.ToArray();
    

    To get the value of the data by using key

    var details = ((IDictionary)firstRow);
    var vallues= details[Heading[0]];
    

提交回复
热议问题