I am working on a repository pattern where the API look as follows:
var visitor = repository.Find(x => x.EmailAddress == credentials.EmailAddress &&
x.Password == credentials.Password);
where visitor is a domain object and x represents this domain object. The method signature of the Find method on the repository is:
T Find(Func<T, bool> query);
This is all wonderful until I attempt to use this with Linq2Sql because linq2sql creates its own objects and as a result when I want to call:
context.visitors.FirstOrDefault(query);
there is a type mismatch because linq2sql expects a function of the type it created and not the function I am passing in.