2011-06-29 20:27:07 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq.Expressions;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using Tanshu.Accounts.Entities;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
using NHibernate;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
|
|
|
{
|
2011-06-29 20:27:07 +00:00
|
|
|
|
public class ProductGroupBI : FluentGenericBase<ProductGroup>
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
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()
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-29 20:27:07 +00:00
|
|
|
|
return Query()
|
|
|
|
|
.OrderBy(x => x.SortOrder).Asc
|
|
|
|
|
.ThenBy(x => x.Name).Asc
|
|
|
|
|
.List();
|
|
|
|
|
}
|
|
|
|
|
public new IList<ProductGroup> List(Expression<Func<ProductGroup, bool>> query)
|
|
|
|
|
{
|
|
|
|
|
return Query()
|
|
|
|
|
.Where(query)
|
|
|
|
|
.OrderBy(x => x.SortOrder).Asc
|
|
|
|
|
.ThenBy(x => x.Name).Asc
|
2011-06-23 12:47:48 +00:00
|
|
|
|
.List();
|
2011-01-31 20:33:22 +00:00
|
|
|
|
}
|
2011-02-18 16:54:48 +00:00
|
|
|
|
public IList<string> GetProductGroupTypes()
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
const string query = @"select distinct(pg.GroupType) from ProductGroup pg order by pg.GroupType";
|
|
|
|
|
var hnq = Session.CreateQuery(query);
|
|
|
|
|
return hnq.List<string>();
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
2011-01-31 20:33:22 +00:00
|
|
|
|
public ProductGroup GetProductGroupOfProduct(int productID)
|
|
|
|
|
{
|
|
|
|
|
using (var session = SessionManager.Session)
|
|
|
|
|
{
|
|
|
|
|
var item = (from p in session.QueryOver<Product>()
|
2011-06-23 12:47:48 +00:00
|
|
|
|
where p.ProductID == productID
|
|
|
|
|
select p.ProductGroup).SingleOrDefault<ProductGroup>();
|
2011-01-31 20:33:22 +00:00
|
|
|
|
NHibernateUtil.Initialize(item);
|
|
|
|
|
return item;
|
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|