Exemplo n.º 1
0
 /// <summary>
 /// Stateless Session 을 이용하여, <typeparamref name="T"/>의 엔티티들을 모두 조회합니다.
 /// </summary>
 /// <typeparam name="T">조회할 엔티티의 수형</typeparam>
 public static IList <T> FindAllStateless <T>() where T : IDataObject
 {
     return(FindAllStateless <T>(DetachedCriteria.For <T>(), UnitOfWork.CurrentSession));
 }
 protected static DetachedCriteria WhereNameIn(params string[] names)
 {
     return(DetachedCriteria.For <Parent>().Add(Restrictions.In("Name", names.ToArray())));
 }
Exemplo n.º 3
0
        public async Task IncrementQueryExecutionCount_WhenExplicitQueryIsExecutedAsync()
        {
            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    await(FillDbAsync(s));
                    await(tx.CommitAsync());
                }

            IStatistics stats = Sfi.Statistics;

            stats.Clear();
            using (ISession s = OpenSession())
            {
                var r = await(s.CreateCriteria <Country>().ListAsync());
            }
            Assert.AreEqual(1, stats.QueryExecutionCount);

            stats.Clear();
            using (ISession s = OpenSession())
            {
                var r = await(s.CreateQuery("from Country").ListAsync());
            }
            Assert.AreEqual(1, stats.QueryExecutionCount);

            stats.Clear();

            var driver = Sfi.ConnectionProvider.Driver;

            if (driver.SupportsMultipleQueries)
            {
                using (var s = OpenSession())
                {
                    var r = await(s.CreateMultiQuery().Add("from Country").Add("from Continent").ListAsync());
                }
                Assert.AreEqual(1, stats.QueryExecutionCount);

                stats.Clear();
                using (var s = OpenSession())
                {
                    var r = await(s.CreateMultiCriteria().Add(DetachedCriteria.For <Country>()).Add(DetachedCriteria.For <Continent>()).ListAsync());
                }
                Assert.AreEqual(1, stats.QueryExecutionCount);
            }

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    await(CleanDbAsync(s));
                    await(tx.CommitAsync());
                }
        }
Exemplo n.º 4
0
        private void AddItemSearchCriterias(ICriteria criterias, Search query)
        {
            if (!string.IsNullOrEmpty(query.Wildcard))
            {
                criterias.Add(Subqueries.PropertyIn("BaseRecord", DetachedCriteria.For <DatabaseItem>()
                                                    .Add(Restrictions.InsensitiveLike("Name", string.Format("%{0}%", query.Wildcard.Replace(' ', '%'))))
                                                    .SetProjection(Projections.Property("Record"))));
            }

            if (query.IsRetaliation)
            {
                var subquery = Subqueries.PropertyIn("BaseRecord", DetachedCriteria.For <DatabaseItemStat>()
                                                     .Add(Restrictions.Like("Stat", "retaliation%"))
                                                     .CreateAlias("Parent", "P")
                                                     .SetProjection(Projections.Property("P.Record")));
                criterias.Add(subquery);
            }


            // Add the damage/resist filter
            foreach (string[] filter in query.filters)
            {
                var subquery = Subqueries.PropertyIn("BaseRecord", DetachedCriteria.For <DatabaseItemStat>()
                                                     .Add(Restrictions.In("Stat", filter))
                                                     .CreateAlias("Parent", "P")
                                                     .SetProjection(Projections.Property("P.Record")));

                criterias.Add(subquery);
            }

            // Add the MINIMUM level requirement (if any)
            if (query.MinimumLevel > 0)
            {
                var subquery = Subqueries.PropertyIn("BaseRecord", DetachedCriteria.For <DatabaseItemStat>()
                                                     .Add(Restrictions.Eq("Stat", "levelRequirement"))
                                                     .Add(Restrictions.Ge("Value", query.MinimumLevel))
                                                     .CreateAlias("Parent", "P")
                                                     .SetProjection(Projections.Property("P.Record")));

                criterias.Add(subquery);
            }

            // Add the MAXIMUM level requirement (if any)
            if (query.MaximumLevel < 120 && query.MaximumLevel > 0)
            {
                var subquery = Subqueries.PropertyIn("BaseRecord", DetachedCriteria.For <DatabaseItemStat>()
                                                     .Add(Restrictions.Eq("Stat", "levelRequirement"))
                                                     .Add(Restrictions.Le("Value", query.MaximumLevel))
                                                     .CreateAlias("Parent", "P")
                                                     .SetProjection(Projections.Property("P.Record")));

                criterias.Add(subquery);
            }


            // Equipment Slot
            string[] slot = query.Slot;
            if (slot?.Length > 0)
            {
                criterias.Add(Subqueries.PropertyIn("BaseRecord", DetachedCriteria.For <DatabaseItemStat>()
                                                    .Add(Restrictions.Eq("Stat", "Class"))
                                                    .Add(Restrictions.In("TextValue", slot))
                                                    .CreateAlias("Parent", "P")
                                                    .SetProjection(Projections.Property("P.Record"))));
            }

            // Player Class
            string[] classes = query.Classes.ToArray();
            if (classes.Length > 0)
            {
                criterias.Add(Subqueries.PropertyIn("BaseRecord", DetachedCriteria.For <DatabaseItemStat>()
                                                    .Add(Restrictions.In("Stat", new string[] {
                    "augmentSkill1Extras", "augmentSkill2Extras", "augmentMastery1", "augmentMastery2",
                    "augmentSkill4Extras", "augmentSkill3Extras", "augmentMastery4", "augmentMastery3"
                }))
                                                    .Add(Restrictions.In("TextValue", classes))
                                                    .CreateAlias("Parent", "P")
                                                    .SetProjection(Projections.Property("P.Record"))));
            }


            // Add the quality filter (if not set to 'any'/unknown)

            if (!string.IsNullOrEmpty(query.Rarity))
            {
                string val = null;
                switch (query.Rarity)
                {
                case "Yellow":
                    val = "Magical";
                    break;

                case "Blue":
                    val = "Epic";
                    break;

                case "Epic":
                    val = "Legendary";
                    break;

                case "Green":
                    val = "Rare";
                    break;
                }

                if (!string.IsNullOrEmpty(val))
                {
                    var subquery = Subqueries.PropertyIn("BaseRecord", DetachedCriteria.For <DatabaseItemStat>()
                                                         .Add(Restrictions.Eq("Stat", "itemClassification"))
                                                         .Add(Restrictions.Eq("TextValue", val))
                                                         .CreateAlias("Parent", "P")
                                                         .SetProjection(Projections.Property("P.Record")));
                    criterias.Add(subquery);
                }
            }



#if DEBUG
            //criterias.SetMaxResults(50);
#else
            //criterias.SetMaxResults(500);
#endif
            criterias.CreateAlias("Internal", "db");
        }
 protected static DetachedCriteria WhereNameEquals(string nameToMatch)
 {
     return(DetachedCriteria.For <Parent>().Add(Restrictions.Eq("Name", nameToMatch)));
 }
        public async Task ExecutableCriteriaAsync()
        {
            // All query below don't have sense, are only to test if all needed classes are serializable

            // Basic criterion
            DetachedCriteria dc = DetachedCriteria.For(typeof(Student))
                                  .Add(Expression.Between("Name", "aaaaa", "zzzzz"))
                                  .Add(Expression.EqProperty("Name", "Name"))
                                  .Add(Expression.Ge("Name", "a"))
                                  .Add(Expression.GeProperty("Name", "Name"))
                                  .Add(Expression.Gt("Name", "z"))
                                  .Add(Expression.GtProperty("Name", "Name"))
                                  .Add(Expression.IdEq(1))
                                  .Add(Expression.In("Name", new string[] { "Gavin", "Ralph" }))
                                  .Add(Expression.InsensitiveLike("Name", "GAVIN"))
                                  .Add(Expression.IsEmpty("Enrolments"))
                                  .Add(Expression.IsNotEmpty("Enrolments"))
                                  .Add(Expression.IsNotNull("PreferredCourse"))
                                  .Add(Expression.IsNull("PreferredCourse"))
                                  .Add(Expression.Le("Name", "a"))
                                  .Add(Expression.LeProperty("Name", "Name"))
                                  .Add(Expression.Lt("Name", "z"))
                                  .Add(Expression.LtProperty("Name", "Name"))
                                  .Add(Expression.Like("Name", "G%"))
                                  .Add(Expression.Not(Expression.Eq("Name", "Ralph")))
                                  .Add(Expression.NotEqProperty("Name", "Name"))
                                  .AddOrder(Order.Asc("StudentNumber"))
                                  .SetProjection(Property.ForName("StudentNumber"));

            await(SerializeAndListAsync(dc));

            // Like match modes
            dc = DetachedCriteria.For(typeof(Student))
                 .Add(Expression.Like("Name", "Gavin", MatchMode.Anywhere))
                 .Add(Expression.Like("Name", "Gavin", MatchMode.End))
                 .Add(Expression.Like("Name", "Gavin", MatchMode.Exact))
                 .Add(Expression.Like("Name", "Gavin", MatchMode.Start));

            await(SerializeAndListAsync(dc));

            // Logical Expression
            dc = DetachedCriteria.For(typeof(Student))
                 .Add(Expression.Or(Expression.Eq("Name", "Ralph"), Expression.Eq("Name", "Gavin")))
                 .Add(
                Expression.And(Expression.Gt("StudentNumber", 1L),
                               Expression.Lt("StudentNumber", 10L)));

            await(SerializeAndListAsync(dc));

            // Projections
            dc = DetachedCriteria.For(typeof(Enrolment))
                 .SetProjection(Projections.Distinct(Projections.ProjectionList()
                                                     .Add(Projections.Property("StudentNumber"), "stNumber")
                                                     .Add(Projections.Property("CourseCode"), "cCode")))
                 .Add(Expression.Lt("StudentNumber", 668L));
            await(SerializeAndListAsync(dc));

            if (TestDialect.SupportsCountDistinct)
            {
                dc = DetachedCriteria.For(typeof(Enrolment))
                     .SetProjection(Projections.Count("StudentNumber").SetDistinct());
                await(SerializeAndListAsync(dc));
            }

            dc = DetachedCriteria.For(typeof(Enrolment))
                 .SetProjection(Projections.ProjectionList()
                                .Add(Projections.Count("StudentNumber"))
                                .Add(Projections.Max("StudentNumber"))
                                .Add(Projections.Min("StudentNumber"))
                                .Add(Projections.Avg("StudentNumber")));
            await(SerializeAndListAsync(dc));

            // Junctions
            dc = DetachedCriteria.For(typeof(Student))
                 .Add(Expression.Conjunction()
                      .Add(Expression.Eq("Name", "Ralph"))
                      .Add(Expression.Eq("StudentNumber", 1L)))
                 .Add(Expression.Disjunction()
                      .Add(Expression.Eq("Name", "Ralph"))
                      .Add(Expression.Eq("Name", "Gavin")));
            await(SerializeAndListAsync(dc));

            // Subquery
            dc = DetachedCriteria.For(typeof(Student))
                 .Add(Property.ForName("StudentNumber").Eq(232L))
                 .SetProjection(Property.ForName("Name"));

            DetachedCriteria dcs = DetachedCriteria.For(typeof(Student))
                                   .Add(Subqueries.PropertyEqAll("Name", dc));

            await(SerializeAndListAsync(dc));

            // SQLCriterion
            dc = DetachedCriteria.For(typeof(Student))
                 .Add(Expression.Sql("{alias}.Name = 'Gavin'"));
            await(SerializeAndListAsync(dc));

            // SQLProjection
            dc = DetachedCriteria.For(typeof(Enrolment))
                 .SetProjection(Projections.SqlProjection("1 as constOne, count(*) as countStar",
                                                          new String[] { "constOne", "countStar" },
                                                          new IType[] { NHibernateUtil.Int32, NHibernateUtil.Int32 }));
            await(SerializeAndListAsync(dc));

            dc = DetachedCriteria.For(typeof(Student))
                 .SetProjection(
                Projections.SqlGroupProjection("COUNT({alias}.studentId), {alias}.preferredCourseCode",
                                               "{alias}.preferredCourseCode",
                                               new string[] { "studentsOfCourse", "CourseCode" },
                                               new IType[] { NHibernateUtil.Int32, NHibernateUtil.Int32 }));
            await(SerializeAndListAsync(dc));

            // Result transformers
            dc = DetachedCriteria.For(typeof(Enrolment))
                 .CreateAlias("Student", "st")
                 .CreateAlias("Course", "co")
                 .SetProjection(Projections.ProjectionList()
                                .Add(Projections.Property("st.Name"), "studentName")
                                .Add(Projections.Property("co.Description"), "courseDescription")
                                )
                 .AddOrder(Order.Desc("studentName"))
                 .SetResultTransformer(Transformers.AliasToBean(typeof(StudentDTO)));
            await(SerializeAndListAsync(dc));
        }
Exemplo n.º 7
0
 public override void LoadRelatedEntities()
 {
     _organizations = DetachedCriteria.For <Organization>()
                      .GetExecutableCriteria(Session).List().OfType <Organization>()
                      .ToDictionary(o => o.GetUniqueKey());
 }
        /// <summary>
        /// Handles the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>A <see cref="Agatha.Common.Response"/></returns>
        public override Response Handle(PatientReminderSearchRequest request)
        {
            var addressCriteria = DetachedCriteria.For <Patient> ("p")
                                  .CreateCriteria("p.Addresses", "addy", JoinType.LeftOuterJoin)
                                  .CreateCriteria("addy.PatientAddressType", JoinType.LeftOuterJoin);

            var phoneCriteria = DetachedCriteria.For <Patient> ("p")
                                .CreateCriteria("p.PhoneNumbers", "ph", JoinType.LeftOuterJoin)
                                .CreateCriteria("ph.PatientPhoneType", JoinType.LeftOuterJoin);

            var criteria = DetachedCriteria.For <Patient> ("p");

            var totalCountCriteria = DetachedCriteria.For <Patient> ("p")
                                     .SetProjection(Projections.RowCount());

            FilteredListCriteria(request, criteria);

            criteria.CreateCriteria("Profile.PatientGender", "g", JoinType.LeftOuterJoin);
            ApplyGenderCriteria(request, criteria);

            FilteredListCriteria(request, totalCountCriteria);

            //FilteredListCriteria ( request, addressCriteria );
            //FilteredListCriteria ( request, phoneCriteria );

            if (!string.IsNullOrEmpty(request.PatientReminderCriteriaDto.SortBy))
            {
                AddOrdersForPropertyName(
                    criteria,
                    request.PatientReminderCriteriaDto.SortBy,
                    request.PatientReminderCriteriaDto.SortDirection == ListSortDirection.Ascending);
                AddOrdersForPropertyName(
                    addressCriteria,
                    request.PatientReminderCriteriaDto.SortBy,
                    request.PatientReminderCriteriaDto.SortDirection == ListSortDirection.Ascending);
                AddOrdersForPropertyName(
                    phoneCriteria,
                    request.PatientReminderCriteriaDto.SortBy,
                    request.PatientReminderCriteriaDto.SortDirection == ListSortDirection.Ascending);
            }

            if (request.PatientReminderCriteriaDto.PageSize > 0)
            {
                var pageSize         = request.PatientReminderCriteriaDto.PageSize;
                var skippedItemCount = request.PatientReminderCriteriaDto.PageIndex * pageSize;
                criteria.SetFirstResult(skippedItemCount).SetMaxResults(pageSize);
                addressCriteria.SetFirstResult(skippedItemCount).SetMaxResults(pageSize);
                phoneCriteria.SetFirstResult(skippedItemCount).SetMaxResults(pageSize);
            }

            var multiCriteria = Session.CreateMultiCriteria()
                                .Add(criteria)
                                .Add(addressCriteria)
                                .Add(phoneCriteria)
                                .Add(totalCountCriteria);

            multiCriteria.SetResultTransformer(new DistinctRootEntityResultTransformer());

            var response = CreateTypedResponse();

            var criteriaList = multiCriteria.List();

            var resultList = new List <PatientReminderResultDto> ();

            Mapper.Map((( IList )criteriaList[0]).OfType <Patient> (), resultList);
            var resultsDto = new PatientReminderResultsDto
            {
                Results       = resultList,
                PageIndex     = request.PatientReminderCriteriaDto.PageIndex,
                SortBy        = request.PatientReminderCriteriaDto.SortBy,
                SortDirection = request.PatientReminderCriteriaDto.SortDirection,
                TotalCount    = ( int )(( ArrayList )criteriaList[3])[0]
            };

            response.PatientReminderResultsDto = resultsDto;
            return(response);
        }
Exemplo n.º 9
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        string partyCode = this.tbPartyCode.Text != string.Empty ? this.tbPartyCode.Text.Trim() : string.Empty;
        string receiver  = this.tbReceiver.Text != string.Empty ? this.tbReceiver.Text.Trim() : string.Empty;
        string startDate = this.tbStartDate.Text != string.Empty ? this.tbStartDate.Text.Trim() : string.Empty;
        string endDate   = this.tbEndDate.Text != string.Empty ? this.tbEndDate.Text.Trim() : string.Empty;
        string itemCode  = this.tbItemCode.Text != string.Empty ? this.tbItemCode.Text.Trim() : string.Empty;
        string currency  = this.tbCurrency.Text != string.Empty ? this.tbCurrency.Text.Trim() : string.Empty;

        DateTime?effDateFrom = null;

        if (startDate != string.Empty)
        {
            effDateFrom = DateTime.Parse(startDate);
        }

        DateTime?effDateTo = null;

        if (endDate != string.Empty)
        {
            effDateTo = DateTime.Parse(endDate).AddDays(1).AddMilliseconds(-1);
        }

        //重新计价
        bool needRecalculate = bool.Parse(TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_RECALCULATE_WHEN_BILL).Value);

        if (needRecalculate)
        {
            IList <ActingBill> allactingBillList = TheActingBillMgr.GetActingBill(partyCode, receiver, effDateFrom, effDateTo, itemCode, currency, this.ModuleType, null, true);

            TheActingBillMgr.RecalculatePrice(allactingBillList, this.CurrentUser);
        }

        IList <ActingBill> actingBillList = TheActingBillMgr.GetActingBill(partyCode, receiver, effDateFrom, effDateTo, itemCode, currency, this.ModuleType, null);



        if (actingBillList != null && actingBillList.Count > 0)
        {
            foreach (ActingBill actingBill in actingBillList)
            {
                actingBill.CurrentBillQty = actingBill.BillQty - actingBill.BilledQty;
                decimal orgAmount = actingBill.UnitPrice * actingBill.CurrentBillQty;
                actingBill.CurrentDiscount = orgAmount - (actingBill.BillAmount - actingBill.BilledAmount);
            }

            IList <Bill> billList = this.TheBillMgr.CreateBill(actingBillList, this.CurrentUser, (this.IsRelease.Checked ? BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT : BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE));
            ;

            DetachedCriteria selectCriteria      = DetachedCriteria.For(typeof(Bill));
            DetachedCriteria selectCountCriteria = DetachedCriteria.For(typeof(Bill))
                                                   .SetProjection(Projections.Count("BillNo"));

            selectCriteria.Add(Expression.Eq("CreateDate", billList[0].CreateDate));
            selectCriteria.Add(Expression.Eq("CreateUser.Code", this.CurrentUser.Code));
            selectCountCriteria.Add(Expression.Eq("CreateDate", billList[0].CreateDate));
            selectCountCriteria.Add(Expression.Eq("CreateUser.Code", this.CurrentUser.Code));

            SearchEvent((new object[] { selectCriteria, selectCountCriteria }), null);

            this.ShowSuccessMessage("MasterData.Bill.BatchCreateSuccessfully");
        }
        else
        {
            this.ShowErrorMessage("Bill.Error.EmptyBillDetail");
        }
    }
        public IList <T> Find <T>(ISession session)
        {
            var criteria = DetachedCriteria.For <T>()
                           .CreateAlias("Payer", "p", JoinType.InnerJoin);

            if (Year != null && Interval != null)
            {
                criteria.Add(Expression.Eq("Period", new Period(Year.Value, Interval.Value)));
            }
            else if (Year != null)
            {
                criteria.Add(Expression.Sql("{alias}.Period like " + String.Format("'{0}-%'", Year)));
            }
            else if (Interval != null)
            {
                criteria.Add(Expression.Sql("{alias}.Period like " + String.Format("'%-{0}'", (int)Interval)));
            }

            if (Region != null)
            {
                criteria.Add(Subqueries.Exists(DetachedCriteria.For <Client>()
                                               .SetProjection(Property.ForName("Id"))
                                               .CreateAlias("Payers", "pc")
                                               .Add(Expression.Eq("HomeRegion", Region))
                                               .Add(Expression.EqProperty("pc.Id", "p.Id"))));
            }

            if (Recipient != null)
            {
                criteria.Add(Expression.Eq("Recipient", Recipient));
            }

            if (!String.IsNullOrEmpty(SearchText))
            {
                var parts = SearchText.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var ids   = parts
                            .Select(p => {
                    uint id;
                    uint.TryParse(p, out id);
                    return(id);
                })
                            .Where(p => p > 0)
                            .ToArray();

                if (ids.Length == parts.Length)
                {
                    criteria.Add(FindActInvoiceIfIds ? Expression.In("Id", ids) : Expression.In("p.Id", ids));
                }
                else
                {
                    criteria.Add(Expression.Like("p.Name", SearchText, MatchMode.Anywhere));
                }
            }

            if (CreatedOn != null)
            {
                criteria.Add(Expression.Ge("CreatedOn", CreatedOn));
            }

            var items = Find <T>(criteria);

            Count = RowsCount;
            Sum   = criteria.SetProjection(Projections.Sum("Sum"))
                    .GetExecutableCriteria(session)
                    .UniqueResult <decimal>();
            return(items);
        }
Exemplo n.º 11
0
    protected override void DoSearch()
    {
        string code      = this.tbFlow.Text != string.Empty ? this.tbFlow.Text.Trim() : string.Empty;
        string partyFrom = this.tbPartyFrom.Text != string.Empty ? this.tbPartyFrom.Text.Trim() : string.Empty;
        string partyTo   = this.tbPartyTo.Text != string.Empty ? this.tbPartyTo.Text.Trim() : string.Empty;
        string locFrom   = this.tbLocFrom.Text != string.Empty ? this.tbLocFrom.Text.Trim() : string.Empty;
        string locTo     = this.tbLocTo.Text != string.Empty ? this.tbLocTo.Text.Trim() : string.Empty;
        string strategy  = this.ddlStrategy.SelectedIndex != -1 ? this.ddlStrategy.SelectedValue : string.Empty;

        if (SearchEvent != null)
        {
            DetachedCriteria selectCriteria      = DetachedCriteria.For(typeof(Flow));
            DetachedCriteria selectCountCriteria = DetachedCriteria.For(typeof(Flow))
                                                   .SetProjection(Projections.ProjectionList()
                                                                  .Add(Projections.Count("Code")));
            selectCriteria.CreateAlias("PartyFrom", "pf");
            selectCriteria.CreateAlias("PartyTo", "pt");
            selectCountCriteria.CreateAlias("PartyFrom", "pf");
            selectCountCriteria.CreateAlias("PartyTo", "pt");

            #region partyFrom
            SecurityHelper.SetPartyFromSearchCriteria(
                selectCriteria, selectCountCriteria, (this.tbPartyFrom != null ? this.tbPartyFrom.Text : null), BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_TRANSFER, this.CurrentUser.Code);
            #endregion

            #region partyTo
            SecurityHelper.SetPartyToSearchCriteria(
                selectCriteria, selectCountCriteria, (this.tbPartyTo != null ? this.tbPartyTo.Text : null), BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_TRANSFER, this.CurrentUser.Code);
            #endregion

            #region flowType

            selectCriteria.Add(Expression.Eq("Type", BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_TRANSFER));
            selectCountCriteria.Add(Expression.Eq("Type", BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_TRANSFER));
            #endregion

            if (code != string.Empty)
            {
                selectCriteria.Add(Expression.Eq("Code", code));
                selectCountCriteria.Add(Expression.Eq("Code", code));
            }

            if (locFrom != string.Empty)
            {
                selectCriteria.Add(Expression.Eq("LocationFrom.Code", locFrom));
                selectCountCriteria.Add(Expression.Eq("LocationFrom.Code", locFrom));
            }
            if (locTo != string.Empty)
            {
                selectCriteria.Add(Expression.Eq("LocationTo.Code", locTo));
                selectCountCriteria.Add(Expression.Eq("LocationTo.Code", locTo));
            }
            if (strategy != string.Empty)
            {
                selectCriteria.Add(Expression.Eq("FlowStrategy", strategy));
                selectCountCriteria.Add(Expression.Eq("FlowStrategy", strategy));
            }

            SearchEvent((new object[] { selectCriteria, selectCountCriteria }), null);
        }
    }
 public NHibernateDynamicQueryGenerator(string alias)
 {
     query = DetachedCriteria.For(typeof(EntityType),alias);
     queryCount = DetachedCriteria.For(typeof(EntityType), alias);
 }
Exemplo n.º 13
0
        public void IncrementQueryExecutionCount_WhenExplicitQueryIsExecuted()
        {
            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    FillDb(s);
                    tx.Commit();
                }

            IStatistics stats = sessions.Statistics;

            stats.Clear();
            using (ISession s = OpenSession())
            {
                var r = s.CreateCriteria <Country>().List();
            }
            Assert.AreEqual(1, stats.QueryExecutionCount);

            stats.Clear();
            using (ISession s = OpenSession())
            {
                var r = s.CreateQuery("from Country").List();
            }
            Assert.AreEqual(1, stats.QueryExecutionCount);

            stats.Clear();
            using (ISession s = OpenSession())
            {
                var r = s.CreateMultiQuery().Add("from Country").Add("from Continent").List();
            }
            Assert.AreEqual(1, stats.QueryExecutionCount);

            stats.Clear();
            using (ISession s = OpenSession())
            {
                var r = s.CreateMultiCriteria().Add(DetachedCriteria.For <Country>()).Add(DetachedCriteria.For <Continent>()).List();
            }
            Assert.AreEqual(1, stats.QueryExecutionCount);

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    CleanDb(s);
                    tx.Commit();
                }
        }
Exemplo n.º 14
0
        public async Task IncrementQueryExecutionCount_WhenExplicitQueryIsExecutedAsync()
        {
            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    await(FillDbAsync(s));
                    await(tx.CommitAsync());
                }

            IStatistics stats = Sfi.Statistics;

            stats.Clear();
            using (ISession s = OpenSession())
            {
                var r = await(s.CreateCriteria <Country>().ListAsync());
            }
            Assert.AreEqual(1, stats.QueryExecutionCount);

            stats.Clear();
            using (ISession s = OpenSession())
            {
                var r = await(s.CreateQuery("from Country").ListAsync());
            }
            Assert.AreEqual(1, stats.QueryExecutionCount);

            stats.Clear();

            var driver = Sfi.ConnectionProvider.Driver;

            if (driver.SupportsMultipleQueries)
            {
#pragma warning disable 618
                using (var s = OpenSession())
                {
                    var r = await(s.CreateMultiQuery().Add("from Country").Add("from Continent").ListAsync());
                }
                Assert.AreEqual(1, stats.QueryExecutionCount);

                stats.Clear();
                using (var s = OpenSession())
                {
                    var r = await(s.CreateMultiCriteria().Add(DetachedCriteria.For <Country>()).Add(DetachedCriteria.For <Continent>()).ListAsync());
                }
                Assert.AreEqual(1, stats.QueryExecutionCount);
#pragma warning restore 618

                stats.Clear();
                using (var s = OpenSession())
                {
                    await(s.CreateQueryBatch()
                          .Add <Country>(s.CreateQuery("from Country"))
                          .Add <Continent>(s.CreateQuery("from Continent"))
                          .ExecuteAsync(CancellationToken.None));
                }
                Assert.That(stats.QueryExecutionCount, Is.EqualTo(1));

                stats.Clear();
                using (var s = OpenSession())
                {
                    await(s.CreateQueryBatch()
                          .Add <Country>(DetachedCriteria.For <Country>())
                          .Add <Continent>(DetachedCriteria.For <Continent>())
                          .ExecuteAsync(CancellationToken.None));
                }
                Assert.That(stats.QueryExecutionCount, Is.EqualTo(1));
            }

            using (ISession s = OpenSession())
                using (ITransaction tx = s.BeginTransaction())
                {
                    await(CleanDbAsync(s));
                    await(tx.CommitAsync());
                }
        }
Exemplo n.º 15
0
        public PageMessage <Endereco> ListarEnderecos(int startIndex, int pageSize, string orderProperty, bool orderAscending)
        {
            var criteria = DetachedCriteria.For <Endereco>();

            return(Page <Endereco>(criteria, startIndex, pageSize, orderProperty, orderAscending));
        }
        public void SubqueriesExpressions()
        {
            DetachedCriteria dc = DetachedCriteria.For(typeof(Student))
                                  .Add(Expression.Eq("Name", "Gavin King"));
            ICriterion c = Subqueries.Eq("Gavin King", dc);

            NHAssert.IsSerializable(c);
            c = Subqueries.EqAll("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Exists(dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Ge("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.GeAll("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.GeSome("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Gt("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.GtAll("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.GtSome("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.In("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Le("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.LeAll("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.LeSome("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Lt("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.LtAll("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.LtSome("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Ne("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.NotExists(dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.NotIn("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyEq("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyEqAll("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGe("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGeAll("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGeSome("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGt("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGtAll("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGtSome("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyIn("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLe("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLeAll("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLeSome("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLt("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLtAll("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLtSome("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyNe("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyNotIn("Name", dc);
            NHAssert.IsSerializable(c);
        }
 public ApplicationsQuery(ISession session)
 {
     _session = session;
     _query   = DetachedCriteria.For <Application>();
 }
Exemplo n.º 18
0
        public void CanExecuteQueryBatch()
        {
            FutureQueryOf <Parent> futureQueryOfParents  = new FutureQueryOf <Parent>(DetachedCriteria.For <Parent>());
            FutureQueryOf <Child>  futureQueryOfChildren = new FutureQueryOf <Child>(DetachedCriteria.For <Child>());

            Assert.AreEqual(0, futureQueryOfParents.Results.Count);

            //This also kills the database, because we use an in
            // memory one ,so we ensure that the code is not
            // executing a second query
            CurrentContext.DisposeUnitOfWork();

            Assert.AreEqual(0, futureQueryOfChildren.Results.Count);
        }
        public OrderLocationTransaction GenerateOrderLocationTransaction(
            OrderDetail orderDetail, Item item, BomDetail bomDetail, Uom uom, int operation,
            string ioType, string transactionType, decimal unitQty, Location loc,
            bool isShipScanHu, int?huLotSize, bool needPrint, string backFlushMethod, string itemVersion, Location rejectLocation)
        {
            OrderLocationTransaction orderLocationTransaction = new OrderLocationTransaction();

            orderLocationTransaction.OrderDetail     = orderDetail;
            orderLocationTransaction.Item            = item;
            orderLocationTransaction.OrderedQty      = unitQty * orderDetail.OrderedQty; //根据unitQty计算实际的订单量
            orderLocationTransaction.Uom             = uom;
            orderLocationTransaction.Operation       = operation;
            orderLocationTransaction.IOType          = ioType;
            orderLocationTransaction.TransactionType = transactionType;
            orderLocationTransaction.UnitQty         = unitQty;
            orderLocationTransaction.Location        = loc;
            orderLocationTransaction.RejectLocation  = rejectLocation;
            orderLocationTransaction.IsShipScanHu    = isShipScanHu;    //仅生产有效
            orderLocationTransaction.BackFlushMethod = backFlushMethod; //生产回冲物料方式
            orderLocationTransaction.ItemVersion     = itemVersion;
            if (huLotSize.HasValue)
            {
                orderLocationTransaction.HuLotSize = int.Parse(Math.Round(huLotSize.Value * unitQty).ToString("0.#########"));
            }
            orderLocationTransaction.NeedPrint  = needPrint;
            orderLocationTransaction.IsAssemble = true;   //默认都安装
            if (bomDetail != null)
            {
                orderLocationTransaction.BomDetail = bomDetail;
                if (bomDetail.StructureType == BusinessConstants.CODE_MASTER_BOM_DETAIL_TYPE_VALUE_O)
                {
                    //如果是选装件,取bomDetail.Priority作为选装件的默认值,0代表默认不装,1代表默认安装
                    orderLocationTransaction.IsAssemble = (bomDetail.Priority != 0);
                }
                #region 取工位和货架

                DetachedCriteria criteria = DetachedCriteria.For(typeof(Flow));
                criteria.Add(Expression.Eq("Code", orderDetail.OrderHead.Flow));

                IList <Flow> flowList = criteriaMgr.FindAll <Flow>(criteria);
                if (flowList != null && flowList.Count > 0)
                {
                    if (flowList[0].Routing != null)
                    {
                        #region 找routingdet
                        DetachedCriteria rcriteria = DetachedCriteria.For(typeof(RoutingDetail));
                        rcriteria.Add(Expression.Eq("Routing.Code", flowList[0].Routing.Code));
                        rcriteria.Add(Expression.Eq("Operation", bomDetail.Operation));

                        IList <RoutingDetail> routingDetailList = criteriaMgr.FindAll <RoutingDetail>(rcriteria);
                        if (routingDetailList != null && routingDetailList.Count > 0)
                        {
                            if (routingDetailList[0].TagNo != null && routingDetailList[0].TagNo != string.Empty)
                            {
                                orderLocationTransaction.TagNo = routingDetailList[0].TagNo;

                                #region 找对应的工位货架
                                DetachedCriteria scriteria = DetachedCriteria.For(typeof(ShelfItem));
                                scriteria.CreateAlias("Shelf", "s");
                                scriteria.Add(Expression.Eq("s.TagNo", orderLocationTransaction.TagNo));
                                scriteria.Add(Expression.Eq("IsActive", true));
                                scriteria.Add(Expression.Eq("Item.Code", orderLocationTransaction.Item.Code));
                                IList <ShelfItem> shelfItemDetailList = criteriaMgr.FindAll <ShelfItem>(scriteria);
                                if (shelfItemDetailList != null && shelfItemDetailList.Count > 0)
                                {
                                    orderLocationTransaction.Shelf = shelfItemDetailList[0].Shelf.Code;
                                }
                                #endregion
                            }
                        }
                        #endregion
                    }
                }
                #endregion
            }
            //箱数
            orderLocationTransaction.Cartons = Convert.ToInt32(orderLocationTransaction.OrderedQty / orderLocationTransaction.Item.UnitCount);

            if (uom.Code != item.Uom.Code)   //和库存单位不一致,需要进行转化
            {
                //单位转化,更改UnitQty和OrderedQty值
                orderLocationTransaction.Uom        = item.Uom;
                orderLocationTransaction.UnitQty    = this.uomConversionMgr.ConvertUomQty(item, uom, unitQty, item.Uom);
                orderLocationTransaction.OrderedQty = this.uomConversionMgr.ConvertUomQty(item, uom, orderLocationTransaction.OrderedQty, item.Uom);

                if (orderLocationTransaction.HuLotSize.HasValue)
                {
                    orderLocationTransaction.HuLotSize = int.Parse(Math.Round(orderLocationTransaction.HuLotSize.Value * orderLocationTransaction.UnitQty).ToString("#"));
                }
            }

            orderDetail.AddOrderLocationTransaction(orderLocationTransaction);
            return(orderLocationTransaction);
        }
Exemplo n.º 20
0
        public async Task MultiplePagingParametersInSingleQueryAsync()
        {
            if (!Dialect.SupportsSubSelectsWithPagingAsInPredicateRhs)
            {
                Assert.Ignore("Current dialect does not support paging within IN sub-queries");
            }

            using (var session = OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    await(session.SaveAsync(new Foo()
                    {
                        Ord = 0, Name = "00"
                    }));
                    await(session.SaveAsync(new Foo()
                    {
                        Ord = 1, Name = "10"
                    }));
                    await(session.SaveAsync(new Foo()
                    {
                        Ord = 2, Name = "10"
                    }));
                    await(session.SaveAsync(new Foo()
                    {
                        Ord = 3, Name = "11"
                    }));
                    await(session.SaveAsync(new Foo()
                    {
                        Ord = 4, Name = "10"
                    }));
                    await(session.SaveAsync(new Foo()
                    {
                        Ord = 5, Name = "10"
                    }));
                    await(session.SaveAsync(new Foo()
                    {
                        Ord = 6, Name = "10"
                    }));
                    await(session.SaveAsync(new Foo()
                    {
                        Ord = 7, Name = "10"
                    }));
                    await(session.SaveAsync(new Foo()
                    {
                        Ord = 8, Name = "10"
                    }));
                    await(session.SaveAsync(new Foo()
                    {
                        Ord = 9, Name = "10"
                    }));

                    // returns 2, 3, 4, 5, 6, 7, 8
                    DetachedCriteria pagedSubquery =
                        DetachedCriteria.For <Foo>()
                        .Add(Restrictions.Like("Name", "1%"))
                        .AddOrder(Order.Asc("Ord"))
                        .SetFirstResult(1)
                        .SetMaxResults(7)
                        .SetProjection(Projections.Property("Id"));

                    var query =
                        session.CreateCriteria <Foo>()
                        .Add(Subqueries.PropertyIn("Id", pagedSubquery))
                        .Add(Restrictions.Like("Name", "%0"))                         // excludes 3
                        .AddOrder(Order.Asc("Ord"))
                        .SetFirstResult(2)
                        .SetMaxResults(3);

                    var list = await(query.ListAsync <Foo>());

                    Assert.That(list.Count, Is.EqualTo(3));
                    Assert.That(list[0].Ord, Is.EqualTo(5));
                    Assert.That(list[1].Ord, Is.EqualTo(6));
                    Assert.That(list[2].Ord, Is.EqualTo(7));
                }
        }
Exemplo n.º 21
0
    protected override void DoSearch()
    {
        if (SearchEvent != null)
        {
            string flow      = this.tbFlow.Text.Trim() != string.Empty ? this.tbFlow.Text.Trim() : string.Empty;
            string region    = this.tbRegion.Text.Trim() != string.Empty ? this.tbRegion.Text.Trim() : string.Empty;
            string startDate = this.tbStartDate.Text.Trim() != string.Empty ? this.tbStartDate.Text.Trim() : string.Empty;
            string endDate   = this.tbEndDate.Text.Trim() != string.Empty ? this.tbEndDate.Text.Trim() : string.Empty;
            string shift     = this.tbShift.Text.Trim() != string.Empty ? this.tbShift.Text.Trim() : string.Empty;
            string item      = this.tbItem.Text.Trim() != string.Empty ? this.tbItem.Text.Trim() : string.Empty;

            #region DetachedCriteria
            DetachedCriteria selectCriteria      = DetachedCriteria.For(typeof(OrderDetailView));
            DetachedCriteria selectCountCriteria = DetachedCriteria.For(typeof(OrderDetailView))
                                                   .SetProjection(Projections.Count("Id"));

            selectCriteria.Add(Expression.Eq("Type", BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION));
            selectCountCriteria.Add(Expression.Eq("Type", BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION));

            //区域权限
            SecurityHelper.SetRegionSearchCriteria(selectCriteria, selectCountCriteria, "PartyTo.Code", this.CurrentUser.Code);
            //订单状态
            OrderHelper.SetActiveOrderStatusCriteria(selectCriteria, "Status");
            OrderHelper.SetActiveOrderStatusCriteria(selectCountCriteria, "Status");

            if (flow != string.Empty)
            {
                selectCriteria.Add(Expression.Eq("Flow", flow));
                selectCountCriteria.Add(Expression.Eq("Flow", flow));
            }
            if (region != string.Empty)
            {
                selectCriteria.Add(Expression.Eq("PartyTo.Code", region));
                selectCountCriteria.Add(Expression.Eq("PartyTo.Code", region));
            }
            if (startDate != string.Empty)
            {
                selectCriteria.Add(Expression.Ge("EffDate", DateTime.Parse(startDate)));
                selectCountCriteria.Add(Expression.Ge("EffDate", DateTime.Parse(startDate)));
            }
            if (endDate != string.Empty)
            {
                selectCriteria.Add(Expression.Lt("EffDate", DateTime.Parse(endDate).AddDays(1)));
                selectCountCriteria.Add(Expression.Lt("EffDate", DateTime.Parse(endDate).AddDays(1)));
            }
            if (shift != string.Empty)
            {
                selectCriteria.Add(Expression.Eq("Shift.Code", shift));
                selectCountCriteria.Add(Expression.Eq("Shift.Code", shift));
            }
            if (item != string.Empty)
            {
                selectCriteria.Add(Expression.Like("Item.Code", item, MatchMode.Start));
                selectCountCriteria.Add(Expression.Like("Item.Code", item, MatchMode.Start));
            }

            #endregion

            SearchEvent((new object[] { selectCriteria, selectCountCriteria }), null);
        }
    }
Exemplo n.º 22
0
    private object[] CollectParam()
    {
        DetachedCriteria selectCriteria      = DetachedCriteria.For(typeof(ActingBillView));
        DetachedCriteria selectCountCriteria = DetachedCriteria.For(typeof(ActingBillView))
                                               .SetProjection(Projections.Count("Id"));

        IDictionary <string, string> alias = new Dictionary <string, string>();

        selectCriteria.CreateAlias("BillAddress", "ba");
        selectCountCriteria.CreateAlias("BillAddress", "ba");

        alias.Add("BillAddress", "ba");

        if (this.tbOrderNo.Text.Trim() != string.Empty)
        {
            selectCriteria.Add(Expression.Eq("OrderNo", this.tbOrderNo.Text.Trim()));
            selectCountCriteria.Add(Expression.Eq("OrderNo", this.tbOrderNo.Text.Trim()));
        }

        if (this.tbReceiptNo.Text.Trim() != string.Empty)
        {
            if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
            {
                selectCriteria.Add(Expression.Eq("ReceiptNo", this.tbReceiptNo.Text.Trim()));
                selectCountCriteria.Add(Expression.Eq("ReceiptNo", this.tbReceiptNo.Text.Trim()));
            }
            else if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
            {
                selectCriteria.Add(Expression.Eq("ExternalReceiptNo", this.tbReceiptNo.Text.Trim()));
                selectCountCriteria.Add(Expression.Eq("ExternalReceiptNo", this.tbReceiptNo.Text.Trim()));
            }
        }

        #region party设置
        if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
        {
            selectCriteria.CreateAlias("ba.Party", "pf");
            selectCountCriteria.CreateAlias("ba.Party", "pf");

            alias.Add("BillAddress.Party", "pf");

            if (this.tbParty.Text.Trim() != string.Empty)
            {
                selectCriteria.Add(Expression.Eq("pf.Code", this.tbParty.Text.Trim()));
                selectCountCriteria.Add(Expression.Eq("pf.Code", this.tbParty.Text.Trim()));
            }
            else
            {
                SecurityHelper.SetPartyFromSearchCriteria(
                    selectCriteria, selectCountCriteria, (this.tbParty != null ? this.tbParty.Text : null), this.ModuleType, this.CurrentUser.Code);
            }
            selectCriteria.Add(Expression.Eq("TransactionType", BusinessConstants.BILL_TRANS_TYPE_PO));
            selectCountCriteria.Add(Expression.Eq("TransactionType", BusinessConstants.BILL_TRANS_TYPE_PO));
        }
        else if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
        {
            selectCriteria.CreateAlias("ba.Party", "pt");
            selectCountCriteria.CreateAlias("ba.Party", "pt");

            alias.Add("BillAddress.Party", "pt");

            if (this.tbParty.Text.Trim() != string.Empty)
            {
                selectCriteria.Add(Expression.Eq("pt.Code", this.tbParty.Text.Trim()));
                selectCountCriteria.Add(Expression.Eq("pt.Code", this.tbParty.Text.Trim()));
            }
            else
            {
                SecurityHelper.SetPartyToSearchCriteria(
                    selectCriteria, selectCountCriteria, (this.tbParty != null ? this.tbParty.Text : null), this.ModuleType, this.CurrentUser.Code);
            }

            selectCriteria.Add(Expression.Eq("TransactionType", BusinessConstants.BILL_TRANS_TYPE_SO));
            selectCountCriteria.Add(Expression.Eq("TransactionType", BusinessConstants.BILL_TRANS_TYPE_SO));
        }
        #endregion

        if (this.tbItem.Text.Trim() != string.Empty)
        {
            selectCriteria.CreateAlias("Item", "it");
            selectCountCriteria.CreateAlias("Item", "it");

            alias.Add("Item", "it");

            selectCriteria.Add(Expression.Eq("it.Code", this.tbItem.Text.Trim()));
            selectCountCriteria.Add(Expression.Eq("it.Code", this.tbItem.Text.Trim()));
        }

        if (this.tbEffectiveDateFrom.Text.Trim() != string.Empty)
        {
            selectCriteria.Add(Expression.Ge("EffectiveDate", DateTime.Parse(this.tbEffectiveDateFrom.Text.Trim())));
            selectCountCriteria.Add(Expression.Ge("EffectiveDate", DateTime.Parse(this.tbEffectiveDateFrom.Text.Trim())));
        }

        if (this.tbEffectiveDateTo.Text.Trim() != string.Empty)
        {
            selectCriteria.Add(Expression.Le("EffectiveDate", DateTime.Parse(this.tbEffectiveDateTo.Text.Trim()).AddDays(1).AddMilliseconds(-1)));
            selectCountCriteria.Add(Expression.Le("EffectiveDate", DateTime.Parse(this.tbEffectiveDateTo.Text.Trim()).AddDays(1).AddMilliseconds(-1)));
        }

        if (ddlIsProvisionalEstimate.SelectedIndex != 0)
        {
            selectCriteria.Add(Expression.Eq("IsProvisionalEstimate", this.ddlIsProvisionalEstimate.SelectedValue == "Y"?true:false));
            selectCountCriteria.Add(Expression.Eq("IsProvisionalEstimate", this.ddlIsProvisionalEstimate.SelectedValue == "Y" ? true : false));
        }
        if (ddlIsCreateBill.SelectedIndex != 0)
        {
            selectCriteria.Add(Expression.Eq("IsCreateBill", this.ddlIsCreateBill.SelectedValue == "Y" ? true : false));
            selectCountCriteria.Add(Expression.Eq("IsCreateBill", this.ddlIsCreateBill.SelectedValue == "Y" ? true : false));
        }

        return(new object[] { selectCriteria, selectCountCriteria, alias });
    }