narsil/Tanshu.Accounts.Repository/FoodTableBI.cs
2014-10-16 16:45:03 +05:30

36 lines
1.0 KiB
C#

using NHibernate;
using Tanshu.Accounts.Entities;
using System.Linq;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
namespace Tanshu.Accounts.Repository
{
public class FoodTableBI : UnitOfWork<FoodTable>
{
public new IList<FoodTable> List()
{
return _session.QueryOver<FoodTable>()
.OrderBy(x => x.SortOrder).Asc
.List();
}
public new IList<FoodTable> List(Expression<Func<FoodTable, bool>> query)
{
return _session.QueryOver<FoodTable>()
.Where(query)
.OrderBy(x => x.SortOrder).Asc
.List();
}
public void UpdateSortOrder(IList<FoodTable> list)
{
for (int i = 0; i < list.Count; i++)
{
var item = list[i];
var foodTable = _session.Get<FoodTable>(item.FoodTableID);
foodTable.SortOrder = i;
_session.Update(foodTable);
}
}
}
}