【发布时间】:2010-08-30 12:21:17
【问题描述】:
在将 Fluent NHibernate 与自动映射结合使用时,我在使用 CreateCriteria 向条件查询中添加外连接时遇到问题。
这是我的实体 -
public class Table1 : Entity
{
virtual public int tb1_id { get; set; }
virtual public DateTime tb1_date_filed { get; set; }
.
.
.
virtual public IList<Table2> table2 { get; set; }
}
public class Table2: Entity
{
public virtual int tb2_id { get; set; }
public virtual int tb2_seqno { get; set; }
.
.
.
public virtual Table2 table2 { get; set; }
}
我尝试使用以下方法将外部联接添加到我的条件查询中 -
CreateCriteria("Table2", NHibernate.SqlCommand.JoinType.LeftOuterJoin);
但我收到一个错误 -
{"EIX000: (-217) Column (tbl1_id) not found in any table in the query (or SLV is undefined)."}
所以它似乎正在尝试自动设置第二个表的 id,但不知道将其设置为什么。有没有办法可以专门设置id?这是我的会议 -
var persistenceModel = AutoMap.AssemblyOf<Table1>()
.Override<Table1>(c => {
c.Table("case");
c.Id(x => x.id).Column("tbl1_id");
})
.Where(t => t.Namespace == "MyProject.Data.Entities")
.IgnoreBase<Entity>();
希望这有点道理。感谢您的任何想法。
【问题讨论】:
标签: nhibernate fluent-nhibernate