複合キーで多くの-多くのマッピング:
*ブランド
*商品コード
:(*キー表す) を流暢NHibernateは - 私は次のようにテーブル構造を持つアプリケーション開発してい
製品を 商品名
カテゴリー
*区分
CategoryNam製品のための私のマッピングで
public class Product
{
public int ProductID { get; set; }
public string Brand{ get; set; }
public string ProductName { get; set; }
public IEnumerable<Category> { get; set; }
}
public class Category
{
public int CategoryID { get; set; }
public string CategoryName { get; set; }
}
は、次のように
*区分
*商品コード
製品電子
製品のリストは
クラスでのProductID &ブランドの複合IDを持っています、私は
HasManyToMany(x => x.Categories).Table("ProductCategories")
.ParentKeyColumn(NameOf<Product>.Property(p => p.ProductID))
.ChildKeyColumn(NameOf<Category>.Property(p => p.CategoryID))
.Cascade.All();
したがって、基本的に、ProductCategoriesテーブルのProductIDに基づいてカテゴリを選択しようとしています... これは可能ですか?
However- 私のようなエラーを取得しています:あなたのコードは、ほぼ正しい
HasManyToMany<Category>(x => x.Categories)
.Table("ProductCategories")
.ParentKeyColumn("ProductID")
.ChildKeyColumn("CategoryID")
like-べきか? – Richard
ありがとう – Alex