本文整理汇总了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]);
}
}
示例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;
}
示例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);
}
}
示例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();
}
示例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;
}
示例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;
}
示例7: CreateQuery
public IQuery CreateQuery(ISession session)
{
return session.GetNamedQuery(queryName);
}