using Bootstrap.DataAccess;
using Longbow.Web.Mvc;
using System.Linq;
namespace Bootstrap.Admin.Models
{
public class QueryDictOption : PaginationOption
{
///
/// 字典名称
///
public string Name { get; set; }
///
/// 字典种类
///
public string Define { get; set; }
///
/// 字典表查询
///
///
public QueryData RetrieveData()
{
var data = DictHelper.RetrieveDicts();
if (!string.IsNullOrEmpty(Name))
{
data = data.Where(t => t.Name.Contains(Name));
}
if (!string.IsNullOrEmpty(Define))
{
data = data.Where(t => t.Define.ToString() == Define);
}
var ret = new QueryData();
ret.total = data.Count();
// 通过option.Sort属性判断对那列进行排序,现在对字典表Category列排序
data = Order == "asc" ? data.OrderBy(t => t.Category) : data.OrderByDescending(t => t.Category);
ret.rows = data.Skip(Offset).Take(Limit);
return ret;
}
}
}