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


C# ISession.GetNamedQuery方法代码示例

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


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

示例1: Aggregation

        static void Aggregation(ISession session)
        {
            //            var customers = from c in session.Query<Customer>()
            //                            where c.CustomerAddresses.Count > 0
            //                            select c;
            //            var customers = session.CreateQuery("from Customer c where size(c.CustomerAddresses) > 0").List<Customer>();
            //            Console.WriteLine(customers.Count());

            //            var stats = from c in session.Query<Customer>()
            //                        group c by c.FirstName into grp
            //                        where grp.Count() > 10
            //                        orderby grp.Count() ascending
            //                        select new{grp.Key, Count=grp.Count()};
            //            foreach (var stat in stats)
            //            {
            //                    Console.WriteLine("{0}: {1}", stat.Key, stat.Count);
            //            }

            //            var stats = session.CreateQuery("select c.FirstName, count(c) from Customer c group by c.FirstName having count(c) > 10 order by count(c) asc")
            //                               .List<object[]>();
            var stats = session.GetNamedQuery("FirstNameCountQuery")
                               .SetParameter("mincount", 12)
                               .List<object[]>();
            foreach (var stat in stats)
            {
                Console.WriteLine("{0}: {1}", stat[0], stat[1]);
            }
        }
开发者ID:JamesKovacs,项目名称:NHibernateCourseMaterials,代码行数:28,代码来源:Program.cs

示例2: GetExecutableQuery

		/// <summary>
		/// Get an executable instance of <see cref="IQuery"/>, to actually run the query.
		/// </summary>
		public override IQuery GetExecutableQuery(ISession session)
		{
			IQuery result = session.GetNamedQuery(queryName);
			SetDefaultProperties((ISessionFactoryImplementor)session.SessionFactory);
			SetQueryProperties(result);
			return result;
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:10,代码来源:DetachedNamedQuery.cs

示例3: GetColumns

        private void GetColumns(ISession session)
        {
            IQuery query = session.GetNamedQuery("sp_columns");
            query.SetString("table_name", m_Name);

            IList<sp_column> columns = query
                .SetResultTransformer(Transformers.AliasToBean(typeof(sp_column)))
                .List<sp_column>();

            foreach (sp_column column in columns)
            {
                m_Columns.Add(column.COLUMN_NAME, column);
            }
        }
开发者ID:dblock,项目名称:sncore,代码行数:14,代码来源:DomainClass.cs

示例4: DoInHibernate

 /// <summary>
 /// Gets called by HibernateTemplate with an active
 /// Hibernate Session. Does not need to care about activating or closing
 /// the Session, or handling transactions.
 /// </summary>
 /// <remarks>
 /// <p>
 /// Allows for returning a result object created within the callback, i.e.
 /// a domain object or a collection of domain objects. Note that there's
 /// special support for single step actions: see HibernateTemplate.find etc.
 /// </p>
 /// </remarks>
 public object DoInHibernate(ISession session)
 {
     IQuery queryObject = session.GetNamedQuery(queryName);
     outer.PrepareQuery(queryObject);
     queryObject.SetProperties(valueObject);
     return queryObject.List();
 }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:19,代码来源:HibernateTemplate.cs

示例5: CheckFirstRunTasks

        internal static ISession CheckFirstRunTasks(ISession session)
        {
            // Return quickly
            if (!_firstRunTasksWereExecuted)
                using(new WriteLockDisposable(_firstRunTasksLocker))
                {
                    // Check again inside the lock
                    if (_firstRunTasksWereExecuted) return session;

                    try
                    {
                        // Run first-run tasks

                        // Check the aggregates
                        var maxStatus = session.QueryOver<NodeVersionStatusHistory>()
                            .Select(Projections.Max<NodeVersionStatusHistory>(x => x.Date))
                            .SingleOrDefault<DateTimeOffset>();

                        var maxAggregate = session.QueryOver<AggregateNodeStatus>()
                            .Select(Projections.Max<AggregateNodeStatus>(x => x.StatusDate))
                            .SingleOrDefault<DateTimeOffset>();

                        if (maxStatus > maxAggregate)
                        {
                            var sql = session.GetNamedQuery("AggregateNodeStatus_All")
                                .ExecuteUpdate();
                        }
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error<NhFactoryHelper>("Could not run checks against to ensure that node status aggregates are populated", ex);
                    }
                    finally
                    {
                        _firstRunTasksWereExecuted = true;                        
                    }
                }
            return session;
        }
开发者ID:RebelCMS,项目名称:rebelcmsxu5,代码行数:39,代码来源:NhFactoryHelper.cs

示例6: GetExecutableQuery

 /// <summary>
 /// Get an executable instance of <see cref="IQuery"/>, to actually run the query.
 /// </summary>
 public override IQuery GetExecutableQuery(ISession session)
 {
     IQuery result = session.GetNamedQuery(queryName);
     SetQueryProperties(result);
     return result;
 }
开发者ID:zibler,项目名称:zibler,代码行数:9,代码来源:DetachedNamedQuery.cs

示例7: CreateQuery

 public IQuery CreateQuery(ISession session)
 {
     return session.GetNamedQuery(queryName);
 }
开发者ID:spib,项目名称:nhcontrib,代码行数:4,代码来源:NamedQueryFactoryImpl.cs


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