本文整理汇总了C#中ICriteria.SetCacheable方法的典型用法代码示例。如果您正苦于以下问题:C# ICriteria.SetCacheable方法的具体用法?C# ICriteria.SetCacheable怎么用?C# ICriteria.SetCacheable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICriteria
的用法示例。
在下文中一共展示了ICriteria.SetCacheable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnEvent
public void OnEvent(ICriteria crit)
{
crit.SetCacheable(cacheable);
}
示例2: InitSession
/// <summary>
/// Initializes the session that will be used to enumerate
/// </summary>
private void InitSession()
{
_session = _sessionFactory.OpenSession();
_session.FlushMode = FlushMode.Never;
_tx = _session.BeginTransaction();
try
{
//Handle the case of entity type (InitialLoad)
if (_entityType != null)
{
_criteria = _session.CreateCriteria(_entityType);
_criteria.SetCacheable(false);
//If perform by id, add order to the criteria
if (_performOrderById)
{
IClassMetadata metadata = _sessionFactory.GetClassMetadata(_entityType);
string idPropName = metadata.IdentifierPropertyName;
if (idPropName != null)
_criteria.AddOrder(Order.Asc(idPropName));
}
}
//Handle the case of Persistency.Query (GetEnumerator)
else if (_persistencyQuery != null)
{
string select = _persistencyQuery.SqlQuery;
_query = _session.CreateQuery(select);
object[] preparedValues = _persistencyQuery.Parameters;
if (preparedValues != null)
{
for (int i = 0; i < preparedValues.Length; i++)
{
_query.SetParameter(i, preparedValues[i]);
}
}
_query.SetCacheable(false);
_query.SetFlushMode(FlushMode.Never);
}
else throw new Exception("NHibernateDataEnumerator must receive an Entity Type or a Query");
}
catch(Exception ex)
{
if (_tx != null && _tx.IsActive)
_tx.Rollback();
if (_session.IsOpen)
_session.Close();
throw new Exception("Error while constructing an enumerator", ex);
}
}
开发者ID:GigaSpaces-ProfessionalServices,项目名称:xapnet-templates,代码行数:51,代码来源:NHibernateDataEnumerator.cs