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

29 lines
1.1 KiB
C#

using System.Collections.Generic;
using Tanshu.Accounts.Entities;
using NHibernate;
using System;
namespace Tanshu.Accounts.Repository
{
public class ProductGroupModifierBI : UnitOfWork<ProductGroupModifier>
{
public IList<Modifier> List(Guid productGroupID)
{
var list = (from pgm in _session.QueryOver<ProductGroupModifier>()
where pgm.ProductGroup == null || pgm.ProductGroup.ProductGroupID == productGroupID
select pgm.Modifier).Fetch(x => x.Modifier).Eager.List<Modifier>();
foreach (var item in list)
NHibernateUtil.Initialize(item);
return list;
}
public bool HasCompulsoryModifier(Guid productGroupID)
{
var l = from gf in _session.QueryOver<ProductGroupModifier>()
where gf.ShowAutomatically == true && (gf.ProductGroup == null || gf.ProductGroup.ProductGroupID == productGroupID)
select gf;
int c = l.RowCount();
return c > 0;
}
}
}