“该类型已包含”的定义带有一个函数和一个方法
我有以下代码
public static Func<PurchasingDataContext, int, int, List<Requisition>>
GetRequisitions = CompiledQuery.Compile((PurchasingDataContext context, int userid, int requisitionState)
=> context.Requisitions.Where(r => r.UserId == userid && r.RequisitionId == requisitionState).ToList());
public static List<Requisition> GetRequisitions(int userid, int requisitionState)
{
using (PurchasingDataContext context = new PurchasingDataContext())
{
return GetRequisitions(context, userid, (int)requisitionState);
}
}
,它产生以下错误:
'Purchasing.Data.Requisition' 类型已包含 'GetRequisitions' 的定义
我不太明白为什么,我假设 Func 是一种方法,也许是错误的。在这种情况下,我只是在这里超载。也许是不同的,或者我只是做错了什么。任何建议都会很好,
谢谢威尔
I have the following piece of code
public static Func<PurchasingDataContext, int, int, List<Requisition>>
GetRequisitions = CompiledQuery.Compile((PurchasingDataContext context, int userid, int requisitionState)
=> context.Requisitions.Where(r => r.UserId == userid && r.RequisitionId == requisitionState).ToList());
public static List<Requisition> GetRequisitions(int userid, int requisitionState)
{
using (PurchasingDataContext context = new PurchasingDataContext())
{
return GetRequisitions(context, userid, (int)requisitionState);
}
}
and it is producing the following error:
The type 'Purchasing.Data.Requisition' already contains a definition for 'GetRequisitions'
I dont really understand why, I had assumed, perhaps incorrectly that a Func was a method. In which case I am just overloading here. Perhaps it is different, or I am just doing something wrong. Any advice would be great thanks
Will
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有一个名为
GetRequisitions
的字段(您的Func
委托)并且您有一个同名的方法。这是绝对不允许的。You have a field called
GetRequisitions
(yourFunc
delegate) and you have a method of the same name. That is never allowed.