public IQueryOver <BusByDate, BusByDate> BusByDateGetAllByCriterionAndAllWay(DateTime?date, BusType busType, Route route)
        {
            var query       = _session.QueryOver <BusByDate>();
            var listRoute   = RouteRepository.RouteGetAllById(route.Id).Future().ToList();
            var listRouteId = listRoute.Select(x => x.Id).ToList();

            if (date.HasValue)
            {
                query = query.Where(x => x.Date == date);
            }
            BusType busTypeAlias = null;

            query = query.JoinAlias(x => x.BusType, () => busTypeAlias);
            if (busType != null && busType.Id > 0)
            {
                query = query.Where(() => busTypeAlias.Id == busType.Id);
            }
            Route routeAlias = null;

            query = query.JoinAlias(x => x.Route, () => routeAlias);
            if (route != null && route.Id > 0)
            {
                query = query.AndRestrictionOn(() => routeAlias.Id).IsIn(listRouteId);
            }
            return(query);
        }
 public BusByDateRepository(ISession session)
     : base(session)
 {
     RouteRepository          = new RouteRepository();
     ExpenseRepository        = new ExpenseRepository();
     CostTypeRepository       = new CostTypeRepository();
     ExpenseServiceRepository = new ExpenseServiceRepository();
 }
 public new void Dispose()
 {
     if (RouteRepository != null)
     {
         RouteRepository.Dispose();
         RouteRepository = null;
     }
     if (ExpenseRepository != null)
     {
         ExpenseRepository.Dispose();
         ExpenseRepository = null;
     }
     if (CostTypeRepository != null)
     {
         CostTypeRepository.Dispose();
         CostTypeRepository = null;
     }
     if (ExpenseServiceRepository != null)
     {
         ExpenseServiceRepository.Dispose();
         ExpenseServiceRepository = null;
     }
     base.Dispose();
 }