59909a5ee7
Must use the Repositories with Using or else bad things will happen.
28 lines
931 B
C#
28 lines
931 B
C#
using FluentNHibernate.Conventions;
|
|
using FluentNHibernate.Conventions.Instances;
|
|
using System.Diagnostics;
|
|
|
|
namespace Tanshu.Accounts.SqlDAO
|
|
{
|
|
public class CascadeConvention : IHasManyConvention, IReferenceConvention
|
|
{
|
|
public void Apply(IManyToOneInstance instance)
|
|
{
|
|
var property = instance.Property;
|
|
if (!AttributeChecker.Cascade(property.MemberInfo)) return;
|
|
Trace.TraceInformation("CascadeAll on {0}.{1}", property.DeclaringType.Name, property.Name);
|
|
instance.Cascade.All();
|
|
}
|
|
|
|
public void Apply(IOneToManyCollectionInstance instance)
|
|
{
|
|
var property = instance.Member;
|
|
if (!AttributeChecker.Cascade(property)) return;
|
|
Trace.TraceInformation("CascadeAllDeleteOrphan on {0}.{1}", property.DeclaringType.Name, property.Name);
|
|
instance.Cascade.AllDeleteOrphan();
|
|
}
|
|
}
|
|
}
|
|
|
|
|