Reputation: 305
OK...been looking at most of the topics up here pertaining to L2E and something similar to the IN SQL operator, and while what I've seen as been educating, it's not getting me much closer to solving the problem.
I know that as of EF4, .Contains is available. Here's an example of one that I'm already using that works like a champ to filter based on a string array:
public static IQueryable<TblIssueDetail> FilterByIssueName(this IQueryable<TblIssueDetail> source, string[] issueName)
{
if (null != issueName)
source = issueName.Aggregate(source, (current, word) => current.Where(x => x.IssueName.Contains(word)));
return source;
}
However, when I try a similar technique with an int[] it falls flat on its face.
public static IQueryable<TblIssueDetail> FilterByProviderAffected(this IQueryable<TblIssueDetail> source, int[] providerAffected)
{
if (null != providerAffected)
source = providerAffected.Aggregate(source,
(current, item) =>
current.Where(x => x.ProviderAffected.Equals(item)));
return source;
}
What I'm receiving when debugging is: "Unable to create a constant value of type 'System.Object'. Only primitive types ('such as Int32, String, and Guid') are supported in this context." when I hit the filter with the int[] in it.
Am I just missing something silly and obvious, or am I way, way off base on this?
Upvotes: 0
Views: 74