我是一个新手,正在使用反射技术,在搜索了三天后始终没有结果。希望能得到一些帮助。
我的目标是将 Result 绑定到列表中。
我有一个类:
public class DropdownList
{
public string ID { get; set; }
public string Description { get; set; }
}
我有一个函数:
public static List<DropdownList> getDropdownList(string Method)
{
using (var Context = new WebDataContext())
{
var method = Context.GetType().GetMethod(Method);
if (method == null) throw new InvalidOperationException("Defined DataContext does not have method" + Method);
var result = method.Invoke(Context,null);
var toReturn = (from x in result select new DropdownList { ID = x.???, Description = x.??? }).ToList();
return toReturn;
}
}
我将这个绑定到一个下拉框:
StatuscomboBoxProperties.DataSource = getDropdownList("Get_SupplierList");
在toReturn中的"result"会给出以下错误:
could not find an implementation of the query pattern for source type "system.Reflection.MethodInfo' "Select" not found
我的问题是:如果你将鼠标悬停在结果上,会出现一个“结果视图”,我可以看到从方法返回的数据,但是我该如何将我的列表与该数据绑定?