搜索等效的流利Nhibernate映射 - 映射映射为字典 [英] Search for equivalent Fluent Nhibernate Mapping - Mapping Map as Dictionary

查看:129
本文介绍了搜索等效的流利Nhibernate映射 - 映射映射为字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在NHibernate 2.1中搜索了一个相当于Fluent Mapping的以下基于属性的映射:

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


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

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


}

我无法获得为NHibernate 3.0工作Fluent Mapping。



结束于

  HasManyToMany<物品>()ParentKeyColumn( MainArticle)ChildKyColumn( ChildArticle)AsMap<。&INT GT( 量); 

这会导致非法访问加载集合异常,同时访问字典... <

 

解决方案

c $ c> HasMany(x => x.Bundle).Table(bundles)。KeyColumn(MainArticle)。AsEntityMap(ChildArticle)。Element(Amount,part => part.Type<小数>());

在我的情况下工作。


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...

解决方案

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.

这篇关于搜索等效的流利Nhibernate映射 - 映射映射为字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆