I have a generic method that exists in EntityRepository that gets entities by Name, which is defined as follows:
public IEnumerable<T> GetEntitiesByName<T>(string searchExpression)
where T : class, ISearchableEntity, new()
{
return _session.CreateCriteria<T>()
.Add(LambdaSubquery.Property<Fund>(x => x.Id)
.AddNameSearchCriteria<T>(searchExpression)
.List<T>();
}
There are a number of services that use this method, and everything was fine.. but I now have a requirement that some services require more specific search capabilites than is available in this method.
So I'm wonder if it's possible for me to pass in a DetachedCriteria as an Expression (or something) that I could plug into the query? Each service that needs different functionality could pass in the expression it needs to.
I'm not hugely familiar with NHibernate or Expressions, so I might be out of my depth here. I'm mostly trying to get a feel for what's possible. Otherwise I'll have to abandon the generic method in favour of more specific Repository methods for each service. Thanks.