narsil/Tanshu.Accounts.Repository/BusinessLayer/ProductGroupModifierBI.cs
unknown 59909a5ee7 Updated NH, Code Refactoring, made all DB transactions atomic.
Must use the Repositories with Using or else bad things will happen.
2011-06-30 01:57:07 +05:30

47 lines
1.6 KiB
C#

using System.Collections.Generic;
using Tanshu.Accounts.Entities;
using NHibernate;
namespace Tanshu.Accounts.Repository
{
public class ProductGroupModifierBI : FluentGenericBase<ProductGroupModifier>
{
public ProductGroupModifierBI()
: base()
{ }
public ProductGroupModifierBI(bool beginTransaction)
: base(beginTransaction)
{ }
public ProductGroupModifierBI(ISession session)
: base(session)
{ }
public ProductGroupModifierBI(ISession session, bool beginTransaction)
: base(session, beginTransaction)
{ }
public IList<Modifier> List(int 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(int productGroupID)
{
using (var session = SessionManager.Session)
{
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;
}
}
}
}