私は、SimpleRepositoryが私が探している解決策であると思われるlateとSubSonicのORMを探していました。私自身の属性をSubsonic SimpleRepositoryで使用する
SQLの世代の一部を駆動するために、独自の属性またはSystem.ComponentModel
のものを使用する方法はありますか?モデル/ドメインオブジェクトをサードパーティのものからきれいに保ちたい
私は、SimpleRepositoryが私が探している解決策であると思われるlateとSubSonicのORMを探していました。私自身の属性をSubsonic SimpleRepositoryで使用する
SQLの世代の一部を駆動するために、独自の属性またはSystem.ComponentModel
のものを使用する方法はありますか?モデル/ドメインオブジェクトをサードパーティのものからきれいに保ちたい
これはお勧めできませんが、これを行うことができます。
SubSonics属性(のようなOrmIgnore
の代わりSubSonicIgnore
、まだ取得するSubSonic.Core \拡張\ Object.csから、このコードでSubSonic.SqlGeneration.Schema.IClassMappingAttribute
またはSubSonic.SqlGeneration.Schema.IPropertyMappingAttribute
またはSubSonic.SqlGeneration.Schema.IRelationMappingAttribute
ルックを実装する必要があると一致して、独自の属性を作成します。 。
01:あなたの適用実装はあなたがやりたいようにスキーマを変更する必要があります(SubSonicDefaultSettingAttributeから)このような をpublic static ITable ToSchemaTable(this Type type, IDataProvider provider)
{
...
var typeAttributes = type.GetCustomAttributes(typeof(IClassMappingAttribute), false);
foreach (IClassMappingAttribute attr in typeAttributes)
{
if (attr.Accept(result))
{
attr.Apply(result);
}
}
...
// Now work with attributes
foreach (IPropertyMappingAttribute attr in attributes.Where(x => x is IPropertyMappingAttribute))
{
if (attr.Accept(column))
{
attr.Apply(column);
}
}
....
}
を何が起こっているかのアイデア
public void Apply(IColumn column)
{
column.DefaultSetting = DefaultSetting;
}
あなたは亜音速のソースをチェックアウトし、すべてのカスタム属性をマークする必要があるとして廃止された
[Obsolete("Use OrmIgnore instead", true)]
[AttributeUsage(AttributeTargets.Property)]
public class SubSonicIgnoreAttribute : Attribute { }
あなたが修正する必要があります(インタフェースを使用していない)の属性にはいくつかの直接の言及があります。 。
そして、あなたは、文字列の参照
private static bool ColumnIsIgnored(object[] attributes)
{
foreach (var att in attributes)
{
if (att.ToString().EndsWith("OrmIgnoreAttribute"))
{
return true;
}
}
return false;
}
なぜ-1と
を探す必要があります????? –