narsil/Tanshu.Accounts.Repository/BusinessLayer/ProductGroupBI.cs

50 lines
1.5 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using Tanshu.Accounts.Entities;
using NHibernate;
namespace Tanshu.Accounts.Repository
{
public class ProductGroupBI : FluentBase<ProductGroup>
{
public ProductGroupBI()
: base()
{ }
public ProductGroupBI(bool beginTransaction)
: base(beginTransaction)
{ }
public ProductGroupBI(ISession session)
: base(session)
{ }
public ProductGroupBI(ISession session, bool beginTransaction)
: base(session, beginTransaction)
{ }
public new IList<ProductGroup> List()
{
return Session.QueryOver<ProductGroup>()
.OrderBy(x => x.Name).Asc
.List();
}
public IList<string> GetProductGroupTypes()
{
const string query = @"select distinct(pg.GroupType) from ProductGroup pg order by pg.GroupType";
var hnq = Session.CreateQuery(query);
return hnq.List<string>();
}
public ProductGroup GetProductGroupOfProduct(int productID)
{
using (var session = SessionManager.Session)
{
var item = (from p in session.QueryOver<Product>()
where p.ProductID == productID
select p.ProductGroup).SingleOrDefault<ProductGroup>();
NHibernateUtil.Initialize(item);
return item;
}
}
}
}