Yep, paging is a problem. We have the same feature, called
'parameterized prefetch paths', which works roughly like this: you have a
threshold T which is say by default 100. If there are < T parentID's, it
switches to a where x.FkField in (p1, p...) query for children, and if >= T,
it will use a subquery.
Paging however doesn't work with a subquery, you have to use the
parameterized variant with eager loading. This isn't that hard to achieve
however: just keep the page size < T.
In NH land, the 'T' is the batchsize, but it's not configurable at
runtime, correct? So you can't set it per query. It depends whether a
subquery is faster than a parameterized variant. Speed tests on sqlserver
suggest that when you hit 100 or more parameters, a subquery is quicker, but
complex subqueries could make this number become different, so it is highly
useful to have a configurable batch size.
FB
FB
> NH-2316 <http://216.121.112.228/browse/NH-2316>
Right. Still, if you like to nail stuff down statically, you could do this:
public void SetFetchingBatchSize<TEntity, TTargetEntity>(Expression<Func<TEntity, IEnumerable<TTargetEntity>>> association, int batchSize)
where TEntity: class, TTargetEntity: class
Don’t know, I’m just talking C# here. If you have a OrderItemsCollection type that does not implement IEnumerable<OderItem>, you absolutely need to support IEnumerable, period. I’d rather require the interface, but that’s just me and you have existing code to consider.
IDictionary<TK,TV> would need a separate overload, because while it implements IEnumerable<KeyValuePair<TK,TV>>, KeyValuePair is a struct.
That said, you might be better off just accepting the runtime exception for strings. Your call.
Cheers,
Stefan
public static MemberInfo DecodeMemberAccessExpression<TEntity>(Expression<Func<TEntity, object>> expression)
{
if (expression.Body.NodeType != ExpressionType.MemberAccess)
{
if ((expression.Body.NodeType == ExpressionType.Convert) && (expression.Body.Type == typeof(object)))
{
return ((MemberExpression)((UnaryExpression)expression.Body).Operand).Member;
}
throw new Exception(string.Format("Invalid expression type: Expected ExpressionType.MemberAccess, Found {0}",
expression.Body.NodeType));
}
return ((MemberExpression)expression.Body).Member;
}
I don’t see how catching _some_ errors statically is „useless”. The constraint for non-generic IEnumerable is more expressive too, and costs nil.
From: nhibernate-...@googlegroups.com [mailto:nhibernate-...@googlegroups.com]
On Behalf Of Diego Mijelshon
Sent: Friday, September 03, 2010 1:41 PM
To: nhibernate-...@googlegroups.com
Subject: Re: [nhibernate-development] implementing FetchMode.SubSelect per query, and improving it
You are right.
If you read carefully, I think we all agree on _non-generic_ IEnumerable by now (not object, not IEnumerable<T> either)