Linq to实体不识别方法。
Linq to Entites不识别‘boolealIsCharityMatching(System.String,System.String)’方法,而且此方法无法转换为存储表达式。
ISpecification<Charity> specification = new CharitySearchSpecification(charityTitle, charityReference);charities = charitiesRepository. Find(specification).OrderBy(p => p.RegisteredName).ToList();
public System.Linq.Expressions.Expression<Func<Charity, bool>> IsSatisfied(){ return p => p.IsCharityMatching(this.charityName, this.charityReference);}
public bool IsCharityMatching(string name, string referenceNumber){ bool exists = true; if (!String.IsNullOrEmpty(name)) { if (!this.registeredName.ToLower().Contains(name.ToLower()) && !this.alias.ToLower().Contains(name.ToLower()) && !this.charityId.ToLower().Contains(name.ToLower())) { exists = false; } } if (!String.IsNullOrEmpty(referenceNumber)) { if (!this.charityReference.ToLower().Contains(referenceNumber.ToLower())) { exists = false; } } return exists;}
白板的微信