/// <summary>
        /// Paging extensions of <see cref="IQueryOver{TRoot}"/>
        /// </summary>
        /// <typeparam name="T">{T}</typeparam>
        /// <param name="queryOver"><see cref="IQueryOver{TRoot}"/></param>
        /// <param name="currentPage">Current page</param>
        /// <param name="pageSize">Page size</param>
        /// <param name="records">Records</param>
        /// <returns><see cref="IPaging{T}"/></returns>
        public static IPaging <T> Paging <T>(this IQueryOver <T> queryOver, int currentPage, int pageSize, long?records)
        {
            queryOver.Skip(currentPage * pageSize);
            queryOver.Take(pageSize);

            return(records.HasValue
                       ? queryOver.List <T>().Paging(currentPage, pageSize, records.Value)
                       : queryOver.List <T>().Paging(currentPage, pageSize));
        }
		public DotNetOpenAuth.Messaging.Bindings.CryptoKey GetKey(string bucket, string handle)
		{
			DotNetOpenAuth.Messaging.Bindings.CryptoKey key = null;

			using (IEntityContext context = DependencyInjection.Get<IEntityContext>())
			{
				using (IOAuth2CryptoKeyRepository repository = DependencyInjection.Get<IOAuth2CryptoKeyRepository>(InjectionParameter.Create("context", context)))
				{
					IQueryOver<Entity.OAuth2CryptoKey, Entity.OAuth2CryptoKey> query =
						repository
							.Query()
							.Where(x => x.Bucket == bucket)
							.Where(x => x.Handle == handle);

					Entity.OAuth2CryptoKey _key = query.List().SingleOrDefault();
					if (_key != null)
					{
						key = new DotNetOpenAuth.Messaging.Bindings.CryptoKey(Encoding.Unicode.GetBytes(_key.Secret), new DateTime(_key.ExpiresUtc.Ticks, DateTimeKind.Utc));
					}
				}

				context.Commit();
			}

			return key;
		}
Esempio n. 3
0
        public string GetConcatenatedPhoneNumberString(SMSLeads Mode)
        {
            IQueryOver <Enrollee, Enrollee> query = _session.QueryOver <Enrollee>().Where(x => x.Isexpundged == false && x.IsDeleted == false);

            query.Where(Restrictions.Gt(
                            Projections.SqlFunction("length", NHibernateUtil.String,
                                                    Projections.Property <Enrollee>(b => b.Mobilenumber)),
                            9
                            ));
            switch (Mode)
            {
            case SMSLeads.OnlyPrincipal:
                query.Where(x => x.Parentid < 1);
                break;
            }



            string response = string.Empty;

            foreach (Enrollee item in query.List <Enrollee>())
            {
                if (!response.Contains(item.Mobilenumber))
                {
                    response = response + "," + item.Mobilenumber;
                }
            }

            return(response);
        }
Esempio n. 4
0
        /// <summary>
        /// Load list of T objects that match the specified criteria with support for paging and sorting
        /// </summary>
        /// <param name="paging"></param>
        /// <param name="sorting"></param>
        /// <param name="query">Query used to retrieve the T objects. If not specified, all objects will be returned</param>
        /// <returns></returns>
        public static List <T> Load(PagingOptions paging, SortingOptions <T> sorting, IQueryOver <T, T> useQuery = null)
        {
            IQueryOver <T, T> query = (useQuery == null) ? SessionManager.CurrentSession.QueryOver <T>() : useQuery;

            // Logging the method call
            _logger.Debug("{0}.Load(paging, sorting, useQuery)", typeof(T));
            _logger.Debug("Paging: DontApplyPaging={0} Page={1} ResultsPerPage={2} ItemsCount={3} PageCount={4}", paging.DontApplyPaging, paging.Page, paging.ResultsPerPage, paging.ItemsCount, paging.PageCount);
            _logger.Debug("Sorting: DontApplySorting={0} OrderBy={1} SortOrder={2}", sorting.DontApplySorting, sorting.OrderBy.Body, sorting.SortOrder);

            // Aplly sorting
            if (!sorting.DontApplySorting)
            {
                var order = query.OrderBy(sorting.OrderBy);
                query = (sorting.SortOrder == SortOrder.Ascending) ? order.Asc : order.Desc;
            }

            // Apply paging
            if (!paging.DontApplyPaging)
            {
                // Update the paging object with the total number of records
                // so we can determine how many pages there are available
                UpdatePagingOptions((ICriteria)query.UnderlyingCriteria.Clone(), paging);

                // Limit the query results
                query.UnderlyingCriteria
                .SetFirstResult(paging.ResultsPerPage * paging.Page)
                .SetMaxResults(paging.ResultsPerPage);
            }

            return((List <T>)query.List <T>());
        }
Esempio n. 5
0
        public IList <EnrolleePolicyName> GetEnrolleePolicyNumberName(string phrase)
        {
            IQueryOver <Enrollee, Enrollee> query    = _session.QueryOver <Enrollee>().Where(x => x.IsDeleted == false);
            List <EnrolleePolicyName>       response = new List <EnrolleePolicyName>();

            if (!string.IsNullOrEmpty(phrase))
            {
                //search policy number

                phrase = "%" + phrase + "%";

                query = query.Where(Restrictions.On <Enrollee>(x => x.Policynumber).IsInsensitiveLike(phrase));

                foreach (Enrollee item in query.List().OrderBy(x => x.Policynumber))
                {
                    EnrolleePolicyName itemo = new EnrolleePolicyName
                    {
                        Id           = item.Id,
                        Name         = item.Surname + " " + item.Othernames,
                        Policynumber = item.Policynumber,
                    };

                    response.Add(itemo);
                }
            }

            return(response);
        }
Esempio n. 6
0
        public static IList <T> GetQueryOver <T>(IQueryOver <T, T> query, List <SortOrder <T> > expressionOrder, Pagination pagination)
        {
            if (expressionOrder != null)
            {
                for (int i = 0; i < expressionOrder.Count; i++)
                {
                    var model = expressionOrder[i];
                    IQueryOverOrderBuilder <T, T> sort;
                    if (i > 0)
                    {
                        sort = query.ThenBy(model.value);
                    }
                    else
                    {
                        sort = query.OrderBy(model.value);
                    }
                    if (model.searchType == EnumBase.OrderType.Asc)
                    {
                        query = sort.Asc;
                    }
                    else
                    {
                        query = sort.Desc;
                    }
                }
            }
            if (pagination != null)
            {
                query.Skip((pagination.pageIndex - 1) * pagination.pageSize);
                query.Take(pagination.pageSize);
            }
            var list = query.List <T>();

            return(list);
        }
Esempio n. 7
0
        private IEnumerable <Webpage> GetWebpageCopies(Site @from, Site to, SiteCloneContext siteCloneContext,
                                                       Webpage fromParent = null,
                                                       Webpage toParent   = null)
        {
            IQueryOver <Webpage, Webpage> queryOver =
                _session.QueryOver <Webpage>().Where(webpage => webpage.Site.Id == @from.Id);

            queryOver = fromParent == null
                ? queryOver.Where(webpage => webpage.Parent == null)
                : queryOver.Where(webpage => webpage.Parent.Id == fromParent.Id);

            IList <Webpage> webpages = queryOver.List();

            foreach (Webpage webpage in webpages)
            {
                Webpage copy = webpage.GetCopyForSite(to);
                siteCloneContext.AddEntry(webpage, copy);
                copy.Parent = toParent;
                yield return(copy);

                foreach (Webpage child in GetWebpageCopies(@from, to, siteCloneContext, webpage, copy))
                {
                    yield return(child);
                }
            }
        }
Esempio n. 8
0
        public IList <T> get_with_criteria <T>(QueryOver <T> detachedCriteria) where T : class
        {
            if (detachedCriteria == null)
            {
                Log.bound_to(this).log_a_warning_event_containing("Please ensure you send in a criteria when you want to limit records. Otherwise please consider using GetAll(). Returning empty list.");
                return(null);
            }

            IList <T> list;

            bool not_running_outside_session = session == null;

            if (not_running_outside_session)
            {
                start(false);
            }

            IQueryOver <T, T> criteria = detachedCriteria.GetExecutableQueryOver(session);

            list = criteria.List <T>();

            if (not_running_outside_session)
            {
                finish();
            }

            Log.bound_to(this).log_a_debug_event_containing("Repository found {0} records of type {1} with criteria {2}.", list.Count, typeof(T).Name, detachedCriteria.to_string());

            return(list);
        }
Esempio n. 9
0
        /// <summary>
        /// Crea la DoSearchHeader con i metodi standard.
        /// Se non implementati, vengono usati quelli standard
        /// </summary>
        /// <returns></returns>
        public ICollection <THeader> DoSearchHeader()
        {
            ICollection <THeader> searchHeaderList;
            IQueryOver <T, T>     queryOver = CreateQueryOver();

            queryOver = DecorateCriteria(queryOver);
            queryOver = ExecutePaging(queryOver);
            queryOver = AttachSortExpressions(queryOver);
            queryOver = AttachFilterExpressions(queryOver);
            queryOver = SetProjectionsHeaders(queryOver);
            using (ITransaction transaction = NHibernateSession.BeginTransaction())
            {
                try
                {
                    searchHeaderList = queryOver.List <THeader>();
                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
                return(searchHeaderList);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Selects one instance of an entity.
        /// </summary>
        /// <param name="predicate">The LINQ expression.</param>
        /// <returns></returns>
        public T SelectOne(Expression <Func <T, bool> > predicate)
        {
            using (ISession session = NHibernateHelper.GetCurrentSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        IQueryOver <T> results = session.QueryOver <T>().Where(predicate).Take(1);
                        transaction.Commit();

                        return(results.List().FirstOrDefault());
                    }
                    catch
                    {
                        if (transaction.IsActive)
                        {
                            transaction.Rollback();
                        }

                        throw;
                    }
                    finally
                    {
                        NHibernateHelper.CloseSession();
                    }
                }
            }
        }
Esempio n. 11
0
        public IList <Summary> Query(Dictionary <string, string> queryArg)
        {
            using ISession session = DbFactory.OpenSession();
            IQueryOver <Summary> queries = session.QueryOver <Summary>();

            SetQueryArg(queries.RootCriteria, queryArg);
            return(queries.List());
        }
 public static IEnumerable <TU> Future <T, TU>(this IQueryOver <T> query, IDatabaseProvider databaseProvider)
 {
     if (databaseProvider.SupportFuture)
     {
         return(query.Future <TU>());
     }
     return(query.List <TU>());
 }
Esempio n. 13
0
        protected virtual IList <T> FindInternal(Func <IQueryOver <T, T>, IQueryOver <T, T> > func)
        {
            IQueryOver <T> queryOver = func != null?func(CreateQueryOver()) : CreateQueryOver();

            IList <T> result = queryOver.List <T>();

            return(result);
        }
Esempio n. 14
0
        static public PagedResult <DTO> ToExPagedResults <DTO, Model>(this IQueryOver <Model, Model> query, PartialRetrievingInfo retrievingInfo, IQueryOver <Model, Model> idQuery, Func <IEnumerable <Model>, DTO[]> mappingMethod = null)
            where Model : FMGlobalObject
        {
            IEnumerable <Model> queryEnumerable = null;
            int count = 0;

            query = query.TransformUsing(Transformers.DistinctRootEntity);
            if (retrievingInfo.PageSize > PartialRetrievingInfo.AllElementsPageSize)
            {
                ICriteria countCriteria = CriteriaTransformer.Clone(idQuery.RootCriteria);
                countCriteria.SetProjection(Projections.CountDistinct("GlobalId"));
                IFutureValue <int> rowCountQuery = countCriteria.FutureValue <int>();

                idQuery = (QueryOver <Model, Model>)idQuery.ApplyPaging(retrievingInfo);
                var ids = idQuery.Select(Projections.Distinct(Projections.Property("GlobalId"))).Future <Guid>();
                count = rowCountQuery.Value;

                query           = query.WhereRestrictionOn(x => x.GlobalId).IsIn(ids.ToList());
                queryEnumerable = query.List();
            }
            else
            {
                var ids = idQuery.Select(Projections.Distinct(Projections.Property("GlobalId"))).Future <Guid>();
                query           = query.WhereRestrictionOn(x => x.GlobalId).IsIn(ids.ToList());
                queryEnumerable = query.List();
                count           = queryEnumerable.Count();
            }

            DTO[] list = null;
            if (mappingMethod == null)
            {
                var temp = queryEnumerable.ToList();
                list = Mapper.Map <IEnumerable <Model>, DTO[]>(temp);
            }
            else
            {
                list = mappingMethod(queryEnumerable);
            }
            PagedResult <DTO> res = new PagedResult <DTO>(list, count, retrievingInfo.PageIndex);

            res.RetrievedDateTime = DateTime.UtcNow;
            Log.WriteInfo("Paged result. AllCount:{0},PageIndex:{1},PageSize:{2}", res.AllItemsCount, res.PageIndex, res.Items.Count);
            return(res);
        }
Esempio n. 15
0
        public IList <Video> Get(List <string> ids)
        {
            IQueryOver <Video, Video> criteria = NHibernateSession
                                                 .QueryOver <Video>()
                                                 .Where(video => video.Id.IsIn(ids));

            IList <Video> videos = criteria.List <Video>();

            return(videos);
        }
        /// <summary>
        /// بازیابی تمام کورد ها مربوط به نوع ورودی
        /// </summary>
        /// <returns>لیستی از تمام رکورد های مربوط به نوع انخاب شده</returns>
        public static List <T> RetrieveAll()
        {
            //currentSession = NHibernateHelper.SessionFactory.OpenSession();
            using (ISession session = NHibernateHelper.SessionFactory.OpenSession())
            {
                IQueryOver <T> query = session.QueryOver <T>(typeof(T).Name);

                return(new List <T>(query.List <T>()));
            }
        }
Esempio n. 17
0
        public Student First(Expression <Func <Student, bool> > predicate, bool readOnly = false)
        {
            session.Flush();
            session.Clear();

            IQueryOver <Student, Student> query = session.QueryOver <Student>();

            query.Where(predicate);

            return(query.List <Student>().FirstOrDefault());
        }
Esempio n. 18
0
 public IList <MUser> GetAllUser()
 {
     using (var session = NHIbernateHelper.OpenSession())
     {
         using (var tran = session.BeginTransaction())
         {
             IQueryOver <MUser, MUser> userlist = session.QueryOver <MUser>();
             tran.Commit();
             return(userlist.List());
         }
     }
 }
Esempio n. 19
0
 public IList <MUser> GetUserByName(string name)
 {
     using (var session = NHIbernateHelper.OpenSession())
     {
         using (var tran = session.BeginTransaction())
         {
             IQueryOver <MUser, MUser> userlist = session.QueryOver <MUser>().Where(p => p.UserName == name);
             tran.Commit();
             return(userlist.List());
         }
     }
 }
Esempio n. 20
0
        public Words(ISession session, IHost host, Lesson lesson)
        {
            WordRepository    w_repo = new WordRepository(session);
            IQueryOver <Word> query  = lesson == null?
                                       w_repo.Words(host.CurrentTheme) :
                                           w_repo.Words(lesson);

            words = query.List();

            grades = session.QueryOver <Grade>()
                     .Where(x => x.User == host.User)
                     .List();
        }
Esempio n. 21
0
        public IList <T> get_all <T>() where T : class
        {
            IList <T> list;

            using (ensure_session_started())
            {
                IQueryOver <T, T> criteria = session.QueryOver <T>();
                list = criteria.List <T>();
            }

            Log.bound_to(this).log_a_debug_event_containing("Repository found {0} records of type {1}.", list.Count, typeof(T).Name);

            return(list);
        }
Esempio n. 22
0
        public IEnumerable <DeploymentRequest> GetDeploymentRequests(int startIndex, int maxCount)
        {
            using (var session = OpenSession())
            {
                IQueryOver <DeploymentRequest> deploymentRequests =
                    session.QueryOver <DeploymentRequest>()
                    .OrderBy(dr => dr.DateFinished).Desc
                    .ThenBy(dr => dr.Id).Asc
                    .Skip(startIndex)
                    .Take(maxCount);

                return(deploymentRequests.List());
            }
        }
Esempio n. 23
0
        protected virtual IList <TDto> GetEntities <TEntity, TDto>(
            Action <IQueryOver <TEntity, TEntity> > action = null)
            where TEntity : class, IHasUid
            where TDto : IDto
        {
            IQueryOver <TEntity, TEntity> query = RepositoryFactory.Create <TEntity>().Specify();

            if (action != null)
            {
                action(query);
            }

            return(query.List <TDto>());
        }
Esempio n. 24
0
        public void CanUseExpressionForWhere()
        {
            using (ISession session = Sfi.OpenSession())
            {
                IQueryOver <Item, Item> query = session.QueryOver(() => Item);

                var start = DateTime.UtcNow;

                query
                .Where(GetExpression(start));

                query.List();
            }
        }
Esempio n. 25
0
        public IDictionary <string, int> GetutilizationReport(DateTime start, DateTime End)
        {
            IQueryOver <AuthorizationCode, AuthorizationCode> query = _session.QueryOver <AuthorizationCode>().Where(x => x.IsDeleted == false);


            if (true)
            {
                DateTime datete = Convert.ToDateTime(End);

                int dd    = datete.Day;
                int month = datete.Month;
                int year  = datete.Year;

                string   time    = "23:59";
                DateTime enddate = Convert.ToDateTime(string.Format("{0}/{1}/{2} {3}", month, dd, year, time));
                query.Where(Restrictions.On <AuthorizationCode>(a => a.CreatedOn).IsBetween(start).And(enddate));
            }
            //added else
            else
            {
            }

            IOrderedEnumerable <AuthorizationCode> list = query.List <AuthorizationCode>().OrderBy(x => x.EnrolleeCompany);
            Dictionary <string, int> result             = new Dictionary <string, int>();

            foreach (AuthorizationCode itemm in list)
            {
                if (!string.IsNullOrEmpty(itemm.EnrolleeCompany))
                {
                    if (result.ContainsKey(itemm.EnrolleeCompany))
                    {
                        int count = result[itemm.EnrolleeCompany];
                        count++;
                        result[itemm.EnrolleeCompany] = count;
                    }
                    else
                    {
                        result.Add(itemm.EnrolleeCompany, 1);
                    }
                }
                //added else return null
                else
                {
                    return(null);
                }
            }

            return(result);
        }
Esempio n. 26
0
        public IList <BasicTraffic> GetAllBaiscTrafficsByConditions(TrafficTransferMode TTM, decimal machineID, DateTime fromDate, DateTime toDate, int fromTime, int toTime, int fromRecord, int toRecord, decimal fromIdentifier, decimal toIdentifier, bool IsIntegralConditions)
        {
            IList <BasicTraffic>       BasicTrafficsList      = null;
            IEnumerable <BasicTraffic> BasicTrafficEnumerable = null;
            IQueryOver <BasicTraffic, BasicTraffic> IQueryOverBasicTraffic = null;
            Expression <Func <BasicTraffic, bool> > conditions             = conditions = x => x.Date >= fromDate && x.Date <= toDate && x.Time >= fromTime && x.Time <= toTime && x.Active == true;

            switch (TTM)
            {
            case TrafficTransferMode.Normal:
                IQueryOverBasicTraffic = NHibernateSession.QueryOver <BasicTraffic>()
                                         .Where(conditions);
                BasicTrafficsList = this.GetBasicTrafficsOverMachine(machineID, IQueryOverBasicTraffic);
                break;

            case TrafficTransferMode.RecordBase:
                IQueryOverBasicTraffic = NHibernateSession.QueryOver <BasicTraffic>()
                                         .OrderBy(basicTraffic => basicTraffic.ID).Asc
                                         .Skip(fromRecord - 1)
                                         .Take(toRecord - fromRecord + 1)
                                         .Clone();
                if (IsIntegralConditions)
                {
                    IQueryOverBasicTraffic = IQueryOverBasicTraffic.Where(conditions);
                    BasicTrafficsList      = this.GetBasicTrafficsOverMachine(machineID, IQueryOverBasicTraffic);
                }
                else
                {
                    BasicTrafficsList = IQueryOverBasicTraffic.List <BasicTraffic>();
                }
                break;

            case TrafficTransferMode.IdentifierBase:
                IQueryOverBasicTraffic = NHibernateSession.QueryOver <BasicTraffic>()
                                         .Where(basicTraffic => basicTraffic.ID >= fromIdentifier && basicTraffic.ID <= toIdentifier && basicTraffic.Active)
                                         .Clone();
                if (IsIntegralConditions)
                {
                    IQueryOverBasicTraffic = IQueryOverBasicTraffic.Where(conditions);
                    BasicTrafficsList      = this.GetBasicTrafficsOverMachine(machineID, IQueryOverBasicTraffic);
                }
                else
                {
                    BasicTrafficsList = BasicTrafficEnumerable.ToList <BasicTraffic>();
                }
                break;
            }
            return(BasicTrafficsList);
        }
Esempio n. 27
0
        private IList <BasicTraffic> GetBasicTrafficsOverMachine(decimal machineID, IQueryOver <BasicTraffic, BasicTraffic> IQueryOverBasicTraffic)
        {
            IList <BasicTraffic> BasicTrafficsList = new List <BasicTraffic>();

            if (machineID == 0)
            {
                BasicTrafficsList = IQueryOverBasicTraffic.List <BasicTraffic>();
            }
            else
            {
                BasicTrafficsList = IQueryOverBasicTraffic.JoinQueryOver(basicTraffic => basicTraffic.Clock)
                                    .Where(clock => clock.ID == machineID)
                                    .List <BasicTraffic>();
            }
            return(BasicTrafficsList);
        }
Esempio n. 28
0
        /// <summary>
        /// 按条件查询结果集
        /// </summary>
        /// <param name="predicate">条件</param>
        /// <param name="includeLogicDelete">是否包含逻辑删除的数据</param>
        /// <param name="orderbyStrings">OrderBy条件,支持以下格式:
        /// Name 表示按名称升序排列
        /// Name ASC 表示按名称升序排列
        /// Name DESC 表示按名称降序排列
        /// 其中排序字段名为属性名,大小写必须一致
        /// </param>
        /// <returns>返回的结果集</returns>
        public IList <TEntity> Query(Expression <Func <TEntity, bool> > predicate, bool includeLogicDelete,
                                     params string[] orderbyStrings)
        {
            IQueryOver <TEntity, TEntity> query = includeLogicDelete
                                                     ? session.QueryOver <TEntity>().Where(predicate)
                                                     : session.QueryOver <TEntity>().Where(predicate).Where(
                isLogicDeleteExpression);

            query = orderbyStrings.Select(RepositoryHelper.ParseOrderbyString).
                    Aggregate(query,
                              (current, tup) =>
                              tup.Item2
                              ? current.OrderBy(Projections.Property(tup.Item1)).Desc
                              : current.OrderBy(Projections.Property(tup.Item1)).Asc);
            return(query.List());
        }
Esempio n. 29
0
        public IList <Student> All(Expression <Func <Student, bool> > predicate, bool readOnly = false)
        {
            session.Flush();
            session.Clear();

            IQueryOver <Student, Student> query = session.QueryOver <Student>();

            if (predicate != null)
            {
                query = query.Where(predicate);
            }
            if (readOnly)
            {
                return(query.ReadOnly().List());
            }
            return(query.List());
        }
Esempio n. 30
0
        public IList <QuotaPlanejadoRealizadoPorDataVm> PlanejadoRealizadoPorData(RelatorioAgendamentoFiltroVm filtro)
        {
            //OBS: GROUP BY COM ORDER BY CAUSA UM ERRO UTILIZANDO IQUERYABLE (GetQuery).
            //Por isso tive que utilizar IQueryOver

            //var query = (from quota in _quotas.GetQuery()
            //              group quota by new { quota.CodigoTerminal, quota.Data, quota.Fornecedor.Codigo, quota.Fornecedor.Nome, quota.FluxoDeCarga }
            //                  into agrupador
            //                  select new
            //                  {
            //                      agrupador.Key,
            //                      PlanejadoTotal = agrupador.Sum(x => x.PesoTotal),
            //                      RealizadoTotal = agrupador.Sum(x => x.PesoRealizado)
            //                  }
            //                  ).ToList()
            //                  .OrderBy(x => new{x.Key.CodigoTerminal, x.Key.Data});


            IQueryOver <Quota, Quota> queryOver = ObtemQueryOverComFiltrosAplicados(filtro);
            Fornecedor fornec = null;

            queryOver = queryOver
                        .JoinAlias(x => x.Fornecedor, () => fornec)
                        .SelectList(list => list
                                    .SelectGroup(x => x.CodigoTerminal)
                                    .SelectGroup(x => x.Data)
                                    .SelectGroup(x => x.Fornecedor.Codigo)
                                    .SelectGroup(x => fornec.Nome)
                                    .SelectGroup(x => x.FluxoDeCarga)
                                    .SelectSum(x => x.PesoTotal)
                                    .SelectSum(x => x.PesoRealizado)
                                    ).OrderBy(x => x.CodigoTerminal).Asc.OrderBy(x => x.Data).Asc;

            //tive que utilizar um array de objetos porque na query que executa no banco ainda não tenho o método Descricao() do Enum.
            return(Enumerable.Select <object[], QuotaPlanejadoRealizadoPorDataVm>(queryOver
                                                                                  .List <object[]>(), properties => new QuotaPlanejadoRealizadoPorDataVm
            {
                CodigoTerminal = (string)properties[0],
                Data = ((DateTime)properties[1]).ToShortDateString(),
                NomeDoFornecedor = ((string)properties[2]) + " - " + (string)properties[3],
                FluxoDeCarga = ((Enumeradores.FluxoDeCarga)properties[4]).Descricao(),
                Quota = (decimal)properties[5],
                PesoRealizado = (decimal)properties[6]
            }).ToList());
        }