C# fluent nhibernate映射有许多未使用fetch.join的属性ref
我正在使用Nhibernate 3.2,以及与NH 3.2兼容的FluentNhibernate的构建,我来映射我系统的一个遗留部分。我相信这是可能的,我需要做什么,但需要一些帮助,以正确映射它 我在下面有一个用户类,以及一个应用程序列表C# fluent nhibernate映射有许多未使用fetch.join的属性ref,c#,nhibernate,fluent-nhibernate,fluent-nhibernate-mapping,C#,Nhibernate,Fluent Nhibernate,Fluent Nhibernate Mapping,我正在使用Nhibernate 3.2,以及与NH 3.2兼容的FluentNhibernate的构建,我来映射我系统的一个遗留部分。我相信这是可能的,我需要做什么,但需要一些帮助,以正确映射它 我在下面有一个用户类,以及一个应用程序列表 public class User { public virtual string UserID { get; set; } public virtual int Id { get; set; } public virtual ILi
public class User
{
public virtual string UserID { get; set; }
public virtual int Id { get; set; }
public virtual IList<Application> Applications { get; set; }
}
我有相应的类映射,我认为UserMap就是问题所在
UserMap
public class UserMap : ClassMap<User>
{
public UserMap()
{
Id(x => x.UserID);
HasMany(x => x.Applications)
.AsBag()
.KeyColumn("UserID")
.PropertyRef("Id")
.LazyLoad()
.Inverse();
Table("usertable");
ReadOnly();
}
}
public class ApplicationMap : ClassMap<Application>
{
public ApplicationMap()
{
CompositeId()
.KeyProperty(x => x.ApplicationName)
.KeyProperty(x => x.IdFromUserTable, "UserID");
Table("applicationstable");
}
}
应用程序表
Primary Key - string, ColumnName = UserID
int (Identity) - int, ColumnName = Id
Composite Key - string, ColumnName = ApplicationName
and
int, ColumnName = UserId (references Id column in user table)
我的问题是如何让映射在上述场景中工作
一个警告是:我不能更改数据库的结构,但我可以更改类/类映射
非常感谢你的帮助
PS-我确实通过添加Fetch.Join到HasMany用户映射中来实现这一点,但我更愿意在需要时懒散地评估应用程序列表
谢谢,Mark什么是回迁。加入解决方案?我也有同样的问题。我怀疑99%使用真实系统的程序员都有这个问题,但完全拒绝使用ORM,因为所有文档都假设您完全拥有数据库模式,这是非常罕见的。Fetch.Join解决方案是什么?我也有同样的问题。我怀疑99%使用真实系统的程序员都有这个问题,但完全拒绝使用ORM,因为所有文档都假设您完全拥有数据库模式,这是非常罕见的。
Composite Key - string, ColumnName = ApplicationName
and
int, ColumnName = UserId (references Id column in user table)