Frage

I am trying to use Joseph Albahari's PredicateBuilder with my applications Respository which is giving me the following error:

The best overloaded method match for 'MySite.DAL.Respositories.IMyObjRepository.SearchFor(System.Linq.Expressions.Expression<System.Func<MySite.DAL.MyObj,bool>>)' has some invalid arguments

Signiture for MySite.DAL.Respositories.IMyObjRepository.SearchFor:

public IQueryable<MyObj> SearchFor(Expression<Func<MyObj, Boolean>> predicate)

Code calling SearchFor:

var predicate = PredicateBuilder.True<MySite.DAL.MyObj>();
predicate = predicate.And(a => a.county.name == CountyName);
return _myObjRespository.SearchFor(predicate);

I am aware that I do not need PredicateBuilder for this query - I have simplified it for the purposes of this question. The simplified version still gives the same error.

Any help/ideas/advice appreciated.

Thank you.

War es hilfreich?

Lösung

I have just discovered the type expected in _myObjRespository.SearchFor() did not match the type I was setting/sending in var predicate = PredicateBuilder.True();

MyObj was replacing my object names for security/confidentiality reasons - I accidently replaced the different types on my original post.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top