Dapper可以处理动态列标题 [英] Can Dapper handle dynamic column header

查看:80
本文介绍了Dapper可以处理动态列标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个总是返回字符串列表的存储过程。但是,根据传递给存储过程的参数,字符串列表的列标题将更改。 Dapper能够处理这个吗?如果是这样,应该如何处理?



我真的不关心列标题,我想访问字符串列表,但我不知道知道如何在列标题更改后引用数据。



当前非功能代码:



I have a stored procedure that always returns a list of strings. However, based on the parameters passed to the stored procedure, the column heading for the list of strings will change. Is Dapper able to handle this? If so, how should it be handled?

I don't really care about the column header, I want to access the list of strings, but I don't know how to reference the data since the column header changes.

Current non-functional code:

conn.Open();
var p = new DynamicParameters();
p.Add("Search_Function_CD", searchFunction, DbType.String, ParameterDirection.Input);
p.Add("Search_Value", searchValue, DbType.String, direction: ParameterDirection.Input);
p.Add("o_resultset", dbType: DbType.Object, direction: ParameterDirection.Output);
var Results = (IDictionary<string, object>)conn.Query(sql: CommonConstants.ProcedureConstants.PKG_GET_SEARCH_RESULTS, param: p, commandType: CommandType.StoredProcedure);
foreach (object o in Results)
{
	string element = Results.Values.ElementAt(1) as string;
	searchResults.Add(element);
}
conn.Close();
return searchResults;

推荐答案

这篇关于Dapper可以处理动态列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆