現在のプロジェクトでは、いくつかの異なる永続化レイヤーを試しています。私たちは POCO/PI アプローチを試みています。候補の 1 つは LinqToSql です。私は、POCO とマッピング ファイルが手動で作成された「Pro LINQ Object Relational Mapping with C# 2008」で Vijay Mehta が提示した作業に従っています。
私は次のPOCOを持っています:
namespace CIN.CIN2010.DomainModel.Notifications
{
public abstract class Notification //: Repository.BaseEntity
{
public Notification(int notificationId, OwnerTag owner, DateTime creationDateTime, string message)
{
this._notificatonId = notificationId;
this._owner = owner;
this._creationDateTime = creationDateTime;
this._message = message;
}
// omitted for brevity
}
}
そして、私はマッピングファイルのためにこれを持っています:
<Database Name="CINFulfillment" xmlns="http://schemas.microsoft.com/linqtosql/mapping/2007">
<Table Name="dbo.tblNotifications" >
<Type Name="CIN.CIN2010.DomainModel.Notifications.Notification, CIN.CIN2010.DomainModel" InheritanceCode="0" IsInheritanceDefault="true">
<Column Name="NotificationID" Member="NotificationID" Storage="_NotificationID" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" AutoSync="OnInsert" />
<Column Name="NotificationTypeID" Member="NotificationTypeID" Storage="_NotificationTypeID" DbType="TinyInt NOT NULL" />
<Column Name="OwnerID" Member="OwnerID" Storage="_OwnerID" DbType="Int NOT NULL" />
<Column Name="OwnerTypeID" Member="OwnerTypeID" Storage="_OwnerTypeID" DbType="TinyInt NOT NULL" />
<Column Name="SubTypeID" Member="SubTypeID" Storage="_SubTypeID" DbType="TinyInt NOT NULL" />
<Column Name="CreationDateTime" Member="CreationDateTime" Storage="_CreationDateTime" DbType="SmallDateTime NOT NULL" />
<Column Name="Message" Member="Message" Storage="_Message" DbType="VarChar(255) NOT NULL" CanBeNull="false" />
<Column Name="RequiresAction" Member="RequiresAction" Storage="_RequiresAction" DbType="Bit NOT NULL" />
<Column Name="ActionTypeID" Member="ActionTypeID" Storage="_ActionTypeID" DbType="TinyInt" />
<Column Name="DueDateTime" Member="DueDateTime" Storage="_DueDateTime" DbType="SmallDateTime" />
<Column Name="CompletedDateTime" Member="CompletedDateTime" Storage="_CompletedDateTime" DbType="SmallDateTime" />
<Column Name="CompletedStatusID" Member="CompletedStatusID" Storage="_CompletedStatusID" DbType="TinyInt NOT NULL" />
</Type>
</Table>
</Database>
マッピングソースを読み込もうとすると、エラーが発生します:
失敗した CanInstantiateDataContext CIN.CIN2010.Persistence.L2S.Test テスト メソッド CIN.CIN2010.Persistence.L2S.Test.ContextTests.CanInstantiateDataContext が例外をスローしました: System.TypeInitializationException: 'Nested' の型初期化子が例外をスローしました。---> System.InvalidOperationException: マッピングの問題: タイプ 'CIN.CIN2010.DomainModel.Notifications.Notification' のルートを解決できません..
何か案は?