I am using Entity Framework in my C# based code. I am running into an unexpected weirdness and am looking for suggestions.
Case 1, 2, 3, 4...
Projects:
RivWorks.dll
RivWorks.Service.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();
}
etc
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();
...
}
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?
For those interested in the outcome:
I was missing a simple Using statement at the head of my code.
using System.Linq;
This fixed it right up.