当前位置: 首页>>代码示例>>C#>>正文


C# ISession.CreateCriteria方法代码示例

本文整理汇总了C#中ISession.CreateCriteria方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.CreateCriteria方法的具体用法?C# ISession.CreateCriteria怎么用?C# ISession.CreateCriteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISession的用法示例。


在下文中一共展示了ISession.CreateCriteria方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsExistsCode

       private void IsExistsCode(ISession session, RentOrderDetail rentOrderDetail)
        {
            ICriteria criteria = session.CreateCriteria(typeof(RentOrderDetail));

            ICriterion criterion = null;
            if (rentOrderDetail.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(rentOrderDetail.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("RentOrderID", rentOrderDetail.RentOrder);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.RentOrderIsExistsException();//领用明细单号已经存在
            }
        }
开发者ID:iEasyJob,项目名称:EasyJob,代码行数:25,代码来源:RentOrderDetailController.cs

示例2: Init

        public void Init() {
            _session = _sessionFactory.OpenSession();
            foreach (var killType in new[] { typeof(ContentTypeDefinitionRecord), typeof(ContentPartDefinitionRecord), typeof(ContentFieldDefinitionRecord) }) {
                foreach (var killRecord in _session.CreateCriteria(killType).List()) {
                    _session.Delete(killRecord);
                }
            }
            _session.Flush();
            _session.Close();
            _session.Dispose();
            _session = _sessionFactory.OpenSession();

            var builder = new ContainerBuilder();
            builder.RegisterAutoMocking();
            builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
            builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
            builder.RegisterType(typeof(SettingsFormatter)).As(typeof(ISettingsFormatter));
            builder.RegisterType<Signals>().As<ISignals>();
            builder.RegisterType<StubCacheManager>().As<ICacheManager>();
            builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();

            _session = _sessionFactory.OpenSession();
            builder.RegisterInstance(_transactionManager = new TestTransactionManager(_session)).As<ITransactionManager>();

            _container = builder.Build();

        }
开发者ID:Golone,项目名称:Orchard,代码行数:27,代码来源:ContentDefinitionManagerTests.cs

示例3: IsExists

        private void IsExists(ISession session, StorageAlarm storageAlarm)
        {
            ICriteria criteria = session.CreateCriteria(typeof(StorageAlarm));

            ICriterion criterion = null;
            if (storageAlarm.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(storageAlarm.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("Storehouse", storageAlarm.Storehouse);
            criteria.Add(criterion);

            criterion = Restrictions.Eq("Goods", storageAlarm.Goods);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.StorageAlarmIsExistsException();//库存报警表存在
            }
        }
开发者ID:iEasyJob,项目名称:EasyJob,代码行数:28,代码来源:StorageAlarmController.cs

示例4: IsExists

        private void IsExists(ISession session, SellPriceInfo spi)
        {
            ICriteria criteria = session.CreateCriteria(typeof(SellPriceInfo));

            ICriterion criterion = null;
            if (spi.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(spi.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("Storehouse", spi.Storehouse);
            criteria.Add(criterion);

            criterion = Restrictions.Eq("Goods", spi.Goods);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.SellPriceInfoIsExistsException();//销售价格管理(商品资料子表)已经存在
            }
        }
开发者ID:iEasyJob,项目名称:EasyJob,代码行数:28,代码来源:SellPriceInfoController.cs

示例5: GetAll

		public List<GroupFilter> GetAll(ISession session)
		{
			var gfs = session
				.CreateCriteria(typeof(GroupFilter))
				.List<GroupFilter>();
			return new List<GroupFilter>(gfs);
		}
开发者ID:dizzydezz,项目名称:jmm,代码行数:7,代码来源:GroupFilterRepository.cs

示例6: IsExistsCode

        private void IsExistsCode(ISession session, Employee emp)
        {
            ICriteria criteria = session.CreateCriteria(typeof(Employee));

            ICriterion criterion = null;
            if (emp.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(emp.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("Code", emp.Code);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.EmpCodeIsExistsException();//部门Code已经存在
            }
        }
开发者ID:iEasyJob,项目名称:EasyJob,代码行数:25,代码来源:EmployeeController.cs

示例7: GetSum

        private decimal GetSum(ISession session, Guid accountId, DateTime date, EntryType entryType)
        {
            // TODO : try to get the lamda version working
            // currently gives this error: "could not resolve property" regarding Transaction.Date

            //return session.QueryOver<Entry>().Where(x =>
            //    (x.Account.Id == accountId) &&
            //    (x.Transaction.Date <= date) &&
            //    (x.Type == entryType))
            //    .List()
            //    .Sum(x => x.Amount);

            var entries = session.CreateCriteria<Entry>()
                .Add(Expression.Eq("Type", entryType))
                .Add(Expression.Eq("Account.Id", accountId))
                .CreateCriteria("Transaction")
                    .Add(Expression.Eq("Deleted", false))
                    .Add(Expression.Le("Date", date))
                    .List();

            decimal sum = 0;
            foreach (Entry entry in entries)
            {
                sum += entry.Amount;
            }
            return sum;
        }
开发者ID:spcboog,项目名称:budgomatic,代码行数:27,代码来源:GetAccountBalanceForDateCommand.cs

示例8: Init

        public void Init() {
            var builder = new ContainerBuilder();
            builder.RegisterAutoMocking();
            builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
            builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
            builder.RegisterType(typeof(SettingsFormatter))
                .As(typeof(IMapper<XElement, SettingsDictionary>))
                .As(typeof(IMapper<SettingsDictionary, XElement>));
            builder.RegisterType<Signals>().As<ISignals>();
            builder.RegisterType<StubCacheManager>().As<ICacheManager>();
            builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();

            _container = builder.Build();

            _container.Mock<ISessionLocator>()
                .Setup(x => x.For(It.IsAny<Type>()))
                .Returns(() => _session);

            _session = _sessionFactory.OpenSession();
            foreach (var killType in new[] { typeof(ContentTypeDefinitionRecord), typeof(ContentPartDefinitionRecord), typeof(ContentFieldDefinitionRecord) }) {
                foreach (var killRecord in _session.CreateCriteria(killType).List()) {
                    _session.Delete(killRecord);
                }
            }
            _session.Flush();
        }
开发者ID:rupertwhitlock,项目名称:IncreasinglyAbsorbing,代码行数:26,代码来源:ContentDefinitionManagerTests.cs

示例9: GetReferrerSearchQuery

        public ReferrerSearchQuery GetReferrerSearchQuery(ISession session)
        {
            ReferrerSearchQuery rsq = null;

            if (Id == 0)
            {
                rsq = (ReferrerSearchQuery)session.CreateCriteria(typeof(ReferrerSearchQuery))
                    .Add(Expression.Eq("SearchQuery", SearchQuery))
                    .UniqueResult();

                if (rsq == null)
                {
                    rsq = new ReferrerSearchQuery();
                    rsq.RequestCount = RequestCount;
                }
                else
                {
                    rsq.RequestCount += RequestCount;
                }
            }
            else
            {
                rsq = (ReferrerSearchQuery)session.Load(typeof(ReferrerSearchQuery), Id);
                rsq.RequestCount = RequestCount;
            }

            rsq.SearchQuery = SearchQuery;
            return rsq;
        }
开发者ID:dblock,项目名称:dblog,代码行数:29,代码来源:TransitReferrerSearchQuery.cs

示例10: GetBrowser

        public Browser GetBrowser(ISession session)
        {
            Browser browser = null;
            if (Id == 0)
            {
                browser = (Browser)session.CreateCriteria(typeof(Browser))
                    .Add(Expression.Eq("Name", Name))
                    .Add(Expression.Eq("Platform", Platform))
                    .Add(Expression.Eq("Version", Version))
                    .UniqueResult();

                if (browser == null)
                {
                    browser = new Browser();
                }
            }
            else
            {
                browser = (Browser) session.Load(typeof(Browser), Id);
            }

            browser.Name = Name;
            browser.Version = Version;
            browser.Platform = Platform;

            return browser;
        }
开发者ID:dblock,项目名称:dblog,代码行数:27,代码来源:TransitBrowser.cs

示例11: IsExistsCode

        private void IsExistsCode(ISession session, CheckStockDetail checkStockDetail)
        {
            ICriteria criteria = session.CreateCriteria(typeof(CheckStockDetail));

            ICriterion criterion = null;
            if (checkStockDetail.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(checkStockDetail.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("CheckStockID", checkStockDetail.CheckStock);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.CheckStockIsExistsException();//盘点明细单号已经存在
            }
        }
开发者ID:iEasyJob,项目名称:EasyJob,代码行数:25,代码来源:CheckStockDetailController.cs

示例12: IsExistsCode

        private void IsExistsCode(ISession session, PurOrder pur)
        {
            ICriteria criteria = session.CreateCriteria(typeof(PurOrder));

            ICriterion criterion = null;
            if (pur.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(pur.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("PurOrderCode", pur.PurOrderCode);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.PurOrderIsExistsException();//采购主单号已经存在
            }
        }
开发者ID:iEasyJob,项目名称:EasyJob,代码行数:25,代码来源:PurOrderController.cs

示例13: IsExistsCode

        private void IsExistsCode(ISession session, Storehouse sh)
        {
            ICriteria criteria = session.CreateCriteria(typeof(Storehouse));

            ICriterion criterion = null;
            if (sh.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(sh.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("StoreCode", sh.StoreCode);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.StorehouseCodeIsExistsException();//库存Code已经存在
            }
        }
开发者ID:iEasyJob,项目名称:EasyJob,代码行数:25,代码来源:StorehouseController.cs

示例14: BuildCriteria

		protected virtual ICriteria BuildCriteria(ISession session)
		{
			if (cachedCriteria == null)
			{
				if (detachedCriteria != null)
				{
					cachedCriteria = detachedCriteria.GetExecutableCriteria(session);
				}
				else
				{
					cachedCriteria = session.CreateCriteria(targetType);

					if (criterions != null)
					{
						foreach (var queryCriteria in criterions)
						{
							cachedCriteria.Add(queryCriteria);
						}
					}
				}

				if (orders != null)
				{
					foreach (var order in orders)
					{
						cachedCriteria.AddOrder(order);
					}
				}
			}

			return cachedCriteria;
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:32,代码来源:ARPaginableCriteria.cs

示例15: CreateObjects

		protected void CreateObjects(System.Type rootClass, ISession session)
		{
			criteria = (CriteriaImpl) session.CreateCriteria(rootClass);
			criteriaQuery = new CriteriaQueryTranslator(
				(ISessionFactoryImplementor) factory,
				criteria, criteria.EntityOrClassName, SqlAlias);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:7,代码来源:BaseExpressionFixture.cs


注:本文中的ISession.CreateCriteria方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。