/// <summary>
/// 获取数据列表
/// </summary>
/// <typeparam name="T">MODEL對象</typeparam>
/// <param name="query">query對象</param>
/// <param name="sortExpression">sortExpression</param>
/// <param name="maximumRows">maximumRows</param>
/// <param name="startRowIndex">startRowIndex</param>
/// <returns></returns>
public static IList<T> GetObjectList<T>(Query query, string sortExpression, int maximumRows, int startRowIndex) where T : Entity, new()
{
if (sortExpression == "")
{
sortExpression = "ID DESC";
}
query.Page = Mindscape.LightSpeed.Querying.Page.At(startRowIndex, maximumRows);
query.Order = Order.Parse(sortExpression);
IList<Entity> listx = UnitOfWorkFactory.UnitOfWorkScope.Current.Find(query);
IList<T> list = new List<T>();
foreach (Entity entity in listx)
{
list.Add((T)entity);
}
if (list.Count == 0)
{
list.Add(new T());
}
return list;
}
/// 获取数据列表
/// </summary>
/// <typeparam name="T">MODEL對象</typeparam>
/// <param name="query">query對象</param>
/// <param name="sortExpression">sortExpression</param>
/// <param name="maximumRows">maximumRows</param>
/// <param name="startRowIndex">startRowIndex</param>
/// <returns></returns>
public static IList<T> GetObjectList<T>(Query query, string sortExpression, int maximumRows, int startRowIndex) where T : Entity, new()
{
if (sortExpression == "")
{
sortExpression = "ID DESC";
}
query.Page = Mindscape.LightSpeed.Querying.Page.At(startRowIndex, maximumRows);
query.Order = Order.Parse(sortExpression);
IList<Entity> listx = UnitOfWorkFactory.UnitOfWorkScope.Current.Find(query);
IList<T> list = new List<T>();
foreach (Entity entity in listx)
{
list.Add((T)entity);
}
if (list.Count == 0)
{
list.Add(new T());
}
return list;
}