Castle.ActiveRecord.ActiveRecordBase.SlicedFindAll C# (CSharp) Method

SlicedFindAll() protected static method

Returns a portion of the query results (sliced)
protected static SlicedFindAll ( Type targetType, int firstResult, int maxResults, NHibernate.Criterion.Order orders ) : Array
targetType System.Type The target type.
firstResult int The number of the first row to retrieve.
maxResults int The maximum number of results retrieved.
orders NHibernate.Criterion.Order An of objects.
return System.Array
		protected internal static Array SlicedFindAll(Type targetType, int firstResult, int maxResults,
		                                              Order[] orders, params ICriterion[] criteria)
		{
			EnsureInitialized(targetType);

			ISession session = holder.CreateSession(targetType);

			try
			{
				ICriteria sessionCriteria = session.CreateCriteria(targetType);

				foreach(ICriterion cond in criteria)
				{
					sessionCriteria.Add(cond);
				}

				if (orders != null)
				{
					foreach (Order order in orders)
					{
						sessionCriteria.AddOrder(order);
					}
				}

				sessionCriteria.SetFirstResult(firstResult);
				sessionCriteria.SetMaxResults(maxResults);

				return SupportingUtils.BuildArray(targetType, sessionCriteria.List());
			}
			catch (ValidationException)
			{
				holder.FailSession(session);

				throw;
			}
			catch (Exception ex)
			{
				holder.FailSession(session);

				throw new ActiveRecordException("Could not perform SlicedFindAll for " + targetType.Name, ex);
			}
			finally
			{
				holder.ReleaseSession(session);
			}
		}

Same methods

ActiveRecordBase::SlicedFindAll ( Type targetType, int firstResult, int maxResults ) : Array
ActiveRecordBase::SlicedFindAll ( Type targetType, int firstResult, int maxResults, DetachedCriteria criteria ) : Array
ActiveRecordBase::SlicedFindAll ( Type targetType, int firstResult, int maxResults, NHibernate.Criterion.Order orders, DetachedCriteria criteria ) : Array

Usage Example

Beispiel #1
0
 public static T[] FindAll(ICriterion[] criterias, Order[] orders, int firstResult, int maxresults)
 {
     return((T[])ActiveRecordBase.SlicedFindAll(typeof(T), firstResult, maxresults, orders, criterias));
 }
All Usage Examples Of Castle.ActiveRecord.ActiveRecordBase::SlicedFindAll