我有那些方法: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