C#存储函数字典数据集
应该调用函数并返回数据集,但它没有。调试时没有错误 我计算了“queryFunc”并显示“{Method={System.Data.DataSet EqpSizeGetAll()}” 而不是我的数据集的信息 这是我的密码:C#存储函数字典数据集,c#,.net,function,dictionary,dataset,C#,.net,Function,Dictionary,Dataset,应该调用函数并返回数据集,但它没有。调试时没有错误 我计算了“queryFunc”并显示“{Method={System.Data.DataSet EqpSizeGetAll()}” 而不是我的数据集的信息 这是我的密码: public string DisplayName { get; set; } public string SearchField { get; set; } public string EntityType { get; set; } priva
public string DisplayName { get; set; }
public string SearchField { get; set; }
public string EntityType { get; set; }
private static readonly IDictionary<string, Func<DataSet>> typeaheads =
new Dictionary<string, Func<DataSet>>(StringComparer.InvariantCultureIgnoreCase)
{
{ "EqpSize", EqpSizeGetAll }
};
//private static readonly IDictionary<string, string> dem = new Dictionary<string, string>()
protected void Page_Load(object sender, EventArgs e)
{
Func<DataSet> queryFunc;
if (typeaheads.TryGetValue(EntityType, out queryFunc))
{
for (int i = 0; i < 5; i++)
{
plhEntity.Controls.Add(new LiteralControl(string.Format("<Label><input type=\"checkbox\" value=\"{0}\">Dry Van {1}</Label>", SearchField, i))); //<br/>
}
}
}
private static DataSet EqpSizeGetAll()
{
var demo = "asdas";
string asd = demo;
return BusinessFacadesFactory.CreateBusinessFacade<BFEqpSize>().GetAll();
}
publicstringdisplayname{get;set;}
公共字符串搜索字段{get;set;}
公共字符串EntityType{get;set;}
专用静态只读IDictionary typeaheads=
新字典(StringComparer.InvariantCultureInogoreCase)
{
{“EqpSize”,eqpsizegall}
};
//私有静态只读IDictionary dem=新字典()
受保护的无效页面加载(对象发送方、事件参数e)
{
函数查询函数;
if(typeaheads.TryGetValue(EntityType,out queryFunc))
{
对于(int i=0;i<5;i++)
{
plhEntity.Controls.Add(新的LiteralControl(string.Format(“Dry Van{1}”,SearchField,i));//
}
}
}
私有静态数据集EqpSizeGetAll()
{
var demo=“asdas”;
字符串asd=demo;
返回BusinessFacadesFactory.CreateBusinessFacade().GetAll();
}
您提供的代码不会调用queryFunc
。它应该看起来像queryFunc()
或queryFunc.Invoke()
——但它们都不在您给出的代码中。您是对的。我忘了更新这篇文章,但你给我的答案是调用invoke(),这是我错过的。谢谢你的帮助!