我正在尝试向表IdentityGroup添加映射,其中ManyToMany IdentityUsers认为表IdentityGroupIdentitiy。但是当我添加映射时。结果似乎是交叉连接。
有两个用户的组的预期结果:
Group 1:
User 1
User 2
有两个用户的群组的当前结果:
Group 1:
User 1
User 2
Group 1:
User 1
User 2
我的映射如下所示:
mapping.HasManyToMany<IdentityUser>(x => x.Users)
.Table("IdentityGroupIdentity")
.ParentKeyColumn("identityGroup_cid")
.ChildKeyColumn("identity_cid");
获取数据的代码:
public IQueryable<T> Find<T>(params string[] propertiesToLoad)
{
var query = session.Linq<T>();
foreach (var propName in propertiesToLoad)
query.Expand(propName);
if (typeof(T) is ISoftDeletable)
query.Where(x => !(x as ISoftDeletable).IsDeleted);
return query;
}
[...]
public IQueryable<IdentityGroup> Groups
{
get { return Find<IdentityGroup>(new string[] { "DefaultOrganization", "DefaultLocation", "Users" }); }
}
Ant的想法?
答案 0 :(得分:0)
解决方法是在获取时不“扩展”Users属性...