public static Collections.VirtualList <TEntity> ToVirtualResultLazy <TEntity>(this Colosoft.Query.Queryable queryable, int pageSize = 0, string countExpression = null, string uiContext = null, Colosoft.Query.IQueryResultBindStrategy bindStrategy = null, Colosoft.Query.IQueryResultObjectCreator objectCreator = null) where TEntity : class
        {
            queryable.Require("queryable").NotNull();
            Collections.VirtualListLoader <TEntity>           virtualListLoader = null;
            Colosoft.Query.QueryableExecuterHandler <TEntity> executeSelect     = null;
            if (bindStrategy == null && objectCreator == null)
            {
                var ts = Colosoft.Query.TypeBindStrategyCache.GetItem(typeof(TEntity), t => new Colosoft.Query.QueryResultObjectCreator(t));
                objectCreator = ts;
                bindStrategy  = ts;
            }
            if (bindStrategy == null)
            {
                bindStrategy = new Colosoft.Query.TypeBindStrategy(typeof(TEntity), objectCreator);
            }
            var queryable2 = (Colosoft.Query.Queryable)queryable.Clone();

            if (typeof(Colosoft.Business.IEntity).IsAssignableFrom(typeof(TEntity)))
            {
                virtualListLoader = Colosoft.Business.EntityManager.Instance.GetEntityVirtualListLoader <TEntity>(queryable2, countExpression, true, uiContext, null);
                executeSelect     = (queryable3, dataSource, bindStrategy1, objectCreator1) => queryable3.ExecuteSelectProcessLazyResult <TEntity>(uiContext, null, bindStrategy1, objectCreator1);
            }
            else
            {
                virtualListLoader = new Colosoft.Business.QueryableVirtualListLoader <TEntity>(queryable2, countExpression, bindStrategy, objectCreator, null);
            }
            return(new Business.QueryableVirtualList <TEntity>(queryable2, pageSize, virtualListLoader, executeSelect, null, bindStrategy, objectCreator));
        }
 /// <summary>
 /// Processa a consulta e recupera o resultado como IEntityDescriptors.
 /// </summary>
 /// <typeparam name="TEntity"></typeparam>
 /// <typeparam name="TEntityDescriptor"></typeparam>
 /// <param name="query">Consulta que será utilizada no processamento.</param>
 /// <param name="uiContext"></param>
 /// <returns></returns>
 public static IEnumerable <TEntityDescriptor> ProcessResultDescriptor <TEntity, TEntityDescriptor>(this Colosoft.Query.Queryable query, string uiContext = null) where TEntity : class, Colosoft.Business.IEntity where TEntityDescriptor : IEntityDescriptor
 {
     query.Require("query").NotNull();
     if (Colosoft.Business.EntityManager.Instance == null)
     {
         throw new InvalidOperationException("EntityManager instance is null");
     }
     return(Colosoft.Business.EntityManager.Instance.ProcessResultDescriptor <TEntity, TEntityDescriptor>(query, query.SourceContext, uiContext));
 }
        public static Collections.VirtualList <TProxy> ToProxyVirtualResult <TEntity, TProxy>(this Colosoft.Query.Queryable queryable, int pageSize = 0, string countExpression = null, Func <TEntity, TProxy> proxyCreator = null) where TEntity : new()
        {
            queryable.Require("queryable").NotNull();
            var queryable2    = (Colosoft.Query.Queryable)queryable.Clone();
            var bindStrategy  = Colosoft.Query.TypeBindStrategyCache.GetItem(typeof(TEntity), f => new Colosoft.Query.QueryResultObjectCreator(() => new TEntity()));
            var objectCreator = bindStrategy;

            return(new Business.QueryableVirtualList <TProxy>(queryable2, pageSize, new Colosoft.Business.QueryableVirtualListLoader <TProxy>(queryable2, countExpression, bindStrategy, bindStrategy, proxyCreator != null ? new Func <object, TProxy>(f => proxyCreator((TEntity)f)) : null), null, null, bindStrategy, objectCreator));
        }
 /// <summary>
 /// Processa o resultado da consulta a carrega as entidades de negócio.
 /// </summary>
 /// <typeparam name="TEntity">Tipo da entidade de negócio.</typeparam>
 /// <param name="queryable">Consulta.</param>
 /// <param name="uiContext"></param>
 /// <returns></returns>
 public static IEnumerable <TEntity> ProcessLazyResult <TEntity>(this Colosoft.Query.Queryable queryable, string uiContext = null) where TEntity : class, Colosoft.Business.IEntity
 {
     queryable.Require("queryable").NotNull();
     if (Colosoft.Business.EntityManager.Instance == null)
     {
         throw new InvalidOperationException("EntityManager instance is null");
     }
     return(Colosoft.Business.EntityManager.Instance.ProcessLazyResult <TEntity>(queryable, queryable.SourceContext, uiContext));
 }
        public static Collections.VirtualList <TEntity> ToVirtualResultLazy <TEntity>(this Colosoft.Query.Queryable queryable, int pageSize, Collections.VirtualListLoader <TEntity> listLoader, Colosoft.Query.IQueryResultBindStrategy bindStrategy = null, Colosoft.Query.IQueryResultObjectCreator objectCreator = null) where TEntity : class
        {
            queryable.Require("queryable").NotNull();
            var queryable2 = (Colosoft.Query.Queryable)queryable.Clone();

            Colosoft.Query.QueryableExecuterHandler <TEntity> executeSelect = null;
            if (typeof(Colosoft.Business.IEntity).IsAssignableFrom(typeof(TEntity)))
            {
                executeSelect = (queryable3, dataSource, bindStragety1, objectCreator1) => queryable3.ExecuteSelectProcessLazyResult <TEntity>(null, null, bindStragety1, objectCreator1);
            }
            return(new Business.QueryableVirtualList <TEntity>(queryable2, pageSize, listLoader, executeSelect, null, bindStrategy, objectCreator));
        }