流利Nhibernate问题 [英] Fluent Nhibernate problem

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

问题描述



  public virtual Iesi.Collections.Generic.ISet< long> Blas {get;组; } 

以及我的映射:

<$元素(Value,m => m.Type< long>()); p $ p> mapping.HasMany(x => x.Blas).AsSet

这将创建相关的表格,并添加如下数据:

  X.Blas = new Iesi.Collections.Generic.HashedSet< long>(); 
X.Blas.Add(some_long);

这会将值添加到对象中,但Blas中的值永远不会被保留(X的其他所有内容)





$ p




$ b b

Christian

解决方案

如果通过会话加载X,则blas将使用更改跟踪集合进行初始化。所以不要覆盖它。尝试 X.Blas.Clear(); 而不是 X.Blas = new Iesi.Collections.Generic.HashedSet< long>(); code>


I have this in my entity:

public virtual Iesi.Collections.Generic.ISet<long> Blas { get; set; }

and this for my mapping:

mapping.HasMany(x => x.Blas).AsSet().Element("Value", m => m.Type<long>()); 

This creates the relevant tables and I add data like this:

X.Blas = new Iesi.Collections.Generic.HashedSet<long>();
X.Blas.Add(some_long);

This adds values to the object but the values in Blas are never persisted (everything else of X is).

Can anyone see anything wrong?

Thanks.

Christian

解决方案

if X is loaded through a session then blas is initialized with a changetracking collection. So dont overwrite it. Try X.Blas.Clear(); instead of X.Blas = new Iesi.Collections.Generic.HashedSet<long>();

这篇关于流利Nhibernate问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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