データレイヤにEF 4.1 - コードファーストを使用するWebFormsアプリケーションがあります。私は多対多の関係を持っています。レポジトリパターンをコードファーストで使用して、GridView内で多対多の関係を表示
public class Application
{
public Application()
{
Administrators = new List<User>();
}
public long Id { get; set; }
public string Name { get; set; }
public virtual ICollection<User> Administrators { get; set; }
}
public class User
{
public User()
{
Administrates = new List<Application>();
}
public long Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Username { get; set; }
// Collections
public virtual ICollection<Application> Administrates { get; set; }
}
の構成を仮定すると、管理者は、管理者ごとに1つのレコードの列で、各アプリケーションエンティティのために誰であるかを示すためにGridViewのにバインドされたのObjectDataSourceを実装する方法があり、正しくセットアップされています。今、私はこの問題に取り組むためにViewとStoredProcsでSqlDataSourceを使用していますが、私は自分のデータレイヤーのための1つのアーキテクチャパターンに固執したいと思います。
をために。 GridViewからのデータをDelete、Insert、Updateメソッドにどのようにバインドするのですか? 'void Update(Guid applicationId、Guid userId)'を呼び出し、これらのパラメータを使用してコンテキストオブジェクトから正しいオブジェクトを取得しますか? – bdparrish