我有那些方法:LINQ到实体无法识别方法
public int count(
Guid companyId, Expression<Func<T, bool>> isMatch)
{
var filters = new Expression<Func<T, bool>>[]{
x => x.PriceDefinition.CompanyId == companyId,
isMatch
};
return GetCount(filters);
}
public virtual int GetCount(
IEnumerable<Expression<Func<T, bool>>> filters)
{
IQueryable<T> _query = ObjectSet;
if (filters != null)
{
foreach (var filter in filters)
{
_query = _query.Where(filter);
}
}
return _query.Count();
}
使用:
count(some_guid, x => x.IsMatch(entityId, inviterId, routeId, luggageTypeId));
我得到以下异常:
LINQ to Entities does not recognize the method 'Boolean IsMatch(System.Nullable`1[System.Int64], System.Nullable`1[System.Int64], System.Nullable`1[System.Int64], System.Nullable`1[System.Int64])' method, and this method cannot be translated into a store expression.
什么这是为什么?
我该如何解决?
你的过滤器是什么? – SLaks 2011-05-01 02:27:14
@ SLaks♦:对不起,我用isMatch委托更新了问题。 – Naor 2011-05-01 02:29:07