我是使用反射的新手,经过三天的搜索,我无法得到结果。我会很感激一些帮助。
我想要做的是将结果绑定到一个列表。
我有一堂课:
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 中的“结果”给出以下错误:
could not find an implementation of the query pattern for source type "system.Reflection.MethodInfo' "Select" not found
我的问题是:如果您将鼠标悬停在结果上,则有一个结果视图,我可以看到从该方法返回的数据,但是我将如何将我的列表绑定到该数据。