現在、1つのソリューションに次のものがあります。
- コア プロジェクト (データ アクセス、ビジネス ロジック、データ アクセス用の petapoco、配管など)
- モデルプロジェクト(モデルのみ、属性のみのペタポコデコレーション)
- Web プロジェクト (プレゼンテーション用の MVC プロジェクト
モデルとコアを分けたいのですが、PetaPoco.cs を両方に配置することはできません。それをどのように分離し、モデル プロジェクトの POCO を PetaPoco 属性で装飾することができますか?
Models プロジェクトが Core プロジェクトに依存することは望ましくありません。
POCO をデコレートできるように、この別のクラスを Models プロジェクトだけに作成しましたが、属性が Core PetaPoco プロジェクトによって適切に取得されていません。PocoData に依存しすぎています。
提案?
// Poco's marked [Explicit] require all column properties to be marked
[AttributeUsage(AttributeTargets.Class)]
public class ExplicitColumnsAttribute : Attribute
{
}
// For non-explicit pocos, causes a property to be ignored
[AttributeUsage(AttributeTargets.Property)]
public class IgnoreAttribute : Attribute
{
}
// For explicit pocos, marks property as a column and optionally supplies column name
[AttributeUsage(AttributeTargets.Property)]
public class ColumnAttribute : Attribute
{
public ColumnAttribute() { }
public ColumnAttribute(string name) { Name = name; }
public string Name { get; set; }
}
// For explicit pocos, marks property as a result column and optionally supplies column name
[AttributeUsage(AttributeTargets.Property)]
public class ResultColumnAttribute : ColumnAttribute
{
public ResultColumnAttribute() { }
public ResultColumnAttribute(string name) : base(name) { }
}
// Specify the table name of a poco
[AttributeUsage(AttributeTargets.Class)]
public class TableNameAttribute : Attribute
{
public TableNameAttribute(string tableName)
{
Value = tableName;
}
public string Value { get; private set; }
}
// Specific the primary key of a poco class (and optional sequence name for Oracle)
[AttributeUsage(AttributeTargets.Class)]
public class PrimaryKeyAttribute : Attribute
{
public PrimaryKeyAttribute(string primaryKey)
{
Value = primaryKey;
autoIncrement = true;
}
public string Value { get; private set; }
public string sequenceName { get; set; }
public bool autoIncrement { get; set; }
}
[AttributeUsage(AttributeTargets.Property)]
public class AutoJoinAttribute : Attribute
{
public AutoJoinAttribute() { }
}