How can I use a .ToFutureValue() on the Count() part of the code
snipped below.
In QueryOver there is a ToRowQountQuery()

// PagedResults class
public class PagedResults<T>
{
    private readonly IFutureValue<int> _count;

    public int Count { get { return _count.Value; } }

    public IEnumerable<T> Results { get; private set; }

    public PagedResults(IFutureValue<int> count, IEnumerable<T>
result) { _count = count; Results = result; }
}

// QueryOver works
public static PagedResults<T> AsPagedResult<T>(this IQueryOver<T, T>
queryable, int pageSize, int pageNumber)
{
    return new
PagedResults<T>(queryable.ToRowCountQuery().FutureValue<int>(),
queryable.Skip((pageNumber - 1) * pageSize).Take(pageSize).Future());
}

// How to do this using Linq?
public static PagedResults<T> AsPagedResult<T>(this IQueryable<T>
queryable, int pageSize, int pageNumber)
{
    return new PagedResults<T>(queryable.Count().[ToFutureValue()],
queryable.Skip((pageNumber - 1) *
pageSize).Take(pageSize).ToFuture());
}

-- 
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.

Reply via email to