IoC中,我的两个表是这样设计的
Table1:
id        主键
classid   关联到Table2的id
info      信息

Table2:
id        主键
Name

生成的EntityDesigns中
public interface Table1 : Entity
{
[PrimaryKey]
int ID { get; }
int? ClassID { get; set; }
[SqlType("varchar(100)")]
string info { get; set; }
}

public interface Table2 : Entity
{
[PrimaryKey]
int ID { get; }
[SqlType("varchar(100)")]
string name { get; set; }
}

Table1中的ClassID是Table2中ID的外键
我想要实例化Table1的时候,能够直接自动载入Table2中的ID和Name数据。应该如何做呢?
我这样写正确吗?
public interface Table1 : Entity
{
[PrimaryKey]
int ID { get; }
[FkQuery("ID",Contained = true, LazyLoad = false)]
Table2 table2 { get; set; }
[SqlType("varchar(100)")]
string info { get; set; }
}
刚刚了解NBear,希望大家能多多指点。谢谢!
Posted on 2007-07-17 09:54  李通通  阅读(311)  评论(0编辑  收藏  举报