はい、そうです!私は実際に似たようなことをしましたが、代わりにマーカーインターフェイス(INotCacheable、IComponent)を使用しましたが、マーカーインターフェイスまたは属性はそれほど大きな違いではないはずです。
規則を適用するときは、属性の存在を確認してください:)
編集:
いくつかのコードサンプルを追加する
public class MyMappingConventions : IReferenceConvention, IClassConvention
{
public void Apply(IOneToManyCollectionInstance instance)
{
instance.Key.Column(instance.EntityType.Name + "ID");
instance.LazyLoad();
instance.Inverse();
instance.Cascade.SaveUpdate();
if ((typeof(INotCacheable).IsAssignableFrom(instance.Relationship.Class.GetUnderlyingSystemType())))
return;
instance.Cache.ReadWrite();
}
public void Apply(IClassInstance instance)
{
instance.Table(instance.EntityType.Name + "s");
//If inheriting from IIMutable make it readonly
if ((typeof(IImmutable).IsAssignableFrom(instance.EntityType)))
instance.ReadOnly();
//If not cacheable
if ((typeof(INotCacheable).IsAssignableFrom(instance.EntityType)))
return;
instance.Cache.ReadWrite();
}
}