2011-06-29 20:27:07 +00:00
|
|
|
|
using FluentNHibernate.Conventions;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
using FluentNHibernate.Conventions.Instances;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
using System.Diagnostics;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.SqlDAO
|
|
|
|
|
{
|
|
|
|
|
public class CascadeConvention : IHasManyConvention, IReferenceConvention
|
|
|
|
|
{
|
|
|
|
|
public void Apply(IManyToOneInstance instance)
|
|
|
|
|
{
|
|
|
|
|
var property = instance.Property;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (!AttributeChecker.Cascade(property.MemberInfo)) return;
|
|
|
|
|
Trace.TraceInformation("CascadeAll on {0}.{1}", property.DeclaringType.Name, property.Name);
|
2011-01-31 20:33:22 +00:00
|
|
|
|
instance.Cascade.All();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Apply(IOneToManyCollectionInstance instance)
|
|
|
|
|
{
|
|
|
|
|
var property = instance.Member;
|
2011-02-18 16:54:48 +00:00
|
|
|
|
if (!AttributeChecker.Cascade(property)) return;
|
|
|
|
|
Trace.TraceInformation("CascadeAllDeleteOrphan on {0}.{1}", property.DeclaringType.Name, property.Name);
|
2011-01-31 20:33:22 +00:00
|
|
|
|
instance.Cascade.AllDeleteOrphan();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|