实体框架 - 无法将拉姆达EX pression键入'串',因为它不是一个委托类型 [英] Entity Framework - Cannot convert lambda expression to type 'string' because it is not a delegate type
问题描述
我使用实体框架在我的基于C#的code。我遇到了一个意想不到的怪事,我期待的建议。
I am using Entity Framework in my C# based code. I am running into an unexpected weirdness and am looking for suggestions.
案例1,2,3,4 ...
项目:
RivWorks.dll
RivWorks.Service.dll
RivWorks.Alpha.dll
Case 1, 2, 3, 4...
Projects:
RivWorks.dll
RivWorks.Service.dll
RivWorks.Alpha.dll
样品(所有这些工作):
RivWorks.Alpha.dll:
Samples (all of these work):
RivWorks.Alpha.dll:
public static bool EndNegotitation(long ProductID)
{
var product = (from a in _dbFeed.AutoWithImage
where a.AutoID == ProductID select a).FirstOrDefault();
...
}
RivWorks.Service.dll
public static RivWorks.Model.NegotiationAutos.AutoWithImage
GetProductById(long productId)
{
var myProduct = from a in _dbFeed.AutoWithImage
where a.AutoID == productId select a;
return myProduct.FirstOrDefault();
}
public static List<RivWorks.Model.NegotiationAutos.AutoWithImage>
GetProductByCompany(Guid companyId)
{
var myProduct = from a in _dbFeed.AutoWithImage
where a.CompanyID == companyId select a;
return myProduct.ToList();
}
等
案怪事:
RivWorks.Web.Service.dll(WCF项目)
含有作为其他项目中的相同的参考
Case "weirdness":
RivWorks.Web.Service.dll (WCF project)
Contains the same references as the other projects.
public NegotiateSetup GetSetup(string method, string jsonInput)
{
...
long.TryParse(ProductID, out result);
var product = (from a in _dbFeed.AutoWithImage
where a.AutoID == result select a).FirstOrDefault();
...
}
我收到此编译时错误(何处在我的编辑强调这个词):
无法将拉姆达EX pression键入'串',因为它不是一个委托类型的
I am getting this compile time error (the word "where" is highlighted in my editor):
Cannot convert lambda expression to type 'string' because it is not a delegate type
任何想法什么会导致此?
Any ideas what would cause this?
推荐答案
对于那些有兴趣的结果:
我是缺少一个简单的使用声明在我的code头。
For those interested in the outcome:
I was missing a simple Using statement at the head of my code.
using System.Linq;
这固定它的权利了。
这篇关于实体框架 - 无法将拉姆达EX pression键入'串',因为它不是一个委托类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!