1

I search for a equivalent Fluent Mapping for the following Attribute-based mapping in NHibernate 2.1

[Class(typeof(Article), Table = "ARTIKEL")]
public class Article  {


  [Id(0, Name = "Id", Column = "Id")]
  public virtual int Id { get; set; }


  [Map(0)]
  [Key(1, Column = "MainArticle")]
  [IndexManyToMany(2, ClassType = typeof(Article), Column = "ChildArticle")]
  [Element(3, Column = "Amount", NotNull = true)]
  public virtual IDictionary<Article, decimal> Bundle { get; set; }


}

I am not able to get a working Fluent Mapping for NHibernate 3.0.

I ended up with

HasManyToMany<Article>().ParentKeyColumn("MainArticle").ChildKyColumn("ChildArticle").AsMap<int>("Amount");

This results in a "Illegal acces to loading collection" Exception while access the Dictionary...

Eruphus
  • 83
  • 6

2 Answers2

0
HasManyToMany(x => x.Bundle)
    .ParentKeyColumn("MainArticle")
    .ChildKyColumn("ChildArticle")
    .AsEntityMap("ChildArticle")
    .Element("Amount");
Firo
  • 30,626
  • 4
  • 55
  • 94
0

Finaly i got a working solution:

HasMany(x => x.Bundle).Table("bundles").KeyColumn("MainArticle").AsEntityMap("ChildArticle").Element("Amount", part => part.Type<decimal>());

worked in my case.

Eruphus
  • 83
  • 6