I'm using SharpArch, i extended the Repository adding this methods :
public IQueryable<T> FindAll(Expression<Func<T, bool>> expression)
{
var queryable = Session.Query<T>();
return queryable.Where(expression);
}
public IQueryable<T> FindAll(ISpecification<T> specification)
{
var queryable = Session.Query<T>();
return specification.SatisfyingElementsFrom(queryable);
}
Now i can use lambda expressions and specifications with
nibernate.linq:
var printers = repository.FindAll(x => x.IpAddress != null).ToList();
My problem is that it ignore the Not.Lazyload of my entity map.
instead if i use the FindAll with Dictionary provided by sharpArc it
works correctly without lazy load.
Using reflection this is what they do:
public virtual IList<T> FindAll(IDictionary<string, object>
propertyValuePairs)
{
Check.Require((propertyValuePairs != null) &&
(propertyValuePairs.Count > 0), "propertyValuePairs was null or empty;
it has to have at least one property/value pair in it");
ICriteria criteria = this.Session.CreateCriteria(typeof(T));
foreach (string str in propertyValuePairs.Keys)
{
if (propertyValuePairs[str] != null)
{
criteria.Add(Restrictions.Eq(str, propertyValuePairs[str]));
}
else
{
criteria.Add(Restrictions.IsNull(str));
}
}
return criteria.List<T>();
}
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.