36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using FluentNHibernate.Conventions;
|
|
using FluentNHibernate.Conventions.Instances;
|
|
using Tanshu.Accounts.Contracts;
|
|
using System.Reflection;
|
|
using System.Diagnostics;
|
|
using FluentNHibernate.Conventions.AcceptanceCriteria;
|
|
using FluentNHibernate.Conventions.Inspections;
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
|
|
|