问题描述
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问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!