部分クラスを使用しています。EntityFramework から 1 つのクラスが生成されます。インターフェイスを実装できるように、自分で生成した別のクラス。このインターフェイスが使用されるため、2 つのライブラリ/アセンブリは互いを認識しませんが、共通のインターフェイスを実装できます。
私のカスタム インターフェイスはプロパティ EntityCollection( ITimesheetLabors ) を宣言しますが、私の EntityFramework は EntityCollection(TimesheetLabors) を生成するため、コンパイラは私のクラスが理解できる EntityCollection(ITimesheetLabors) を実装していないことを通知します。ただし、部分クラスに必要なインターフェイスのコレクションを返す最良の方法は何ですか?
部分クラスのコレクション プロパティを取得すると、具象型をインターフェイスにキャストできるように、新しくインスタンス化された EntityCollection を返す必要がありますか? 少しやり過ぎのようです。私は何が欠けていますか?
public interface ITimesheet //My Interface
{
EntityCollection<ITimesheetLabors> Timesheets {get;set;}
}
public partial class Timesheet//Class generated by Entity Framework
{
EntityCollection<TimesheetLabors> Timesheets {get;set;}
}
public partial class Timesheet : ITimesheet //My Partial Class that implements my interface
{
EntityCollection<ITimesheetLabors> Timesheets {get;set;}
}