--生成多表链接语句
var sql = ORM.LeftJoin<tblClass, tblStudent>("c.tblClassID = s.tblClassID")
.GetSql("where c.Mark > 0", "order by CreateDate desc");
--生成多表链接语句(分页:第一页/取10行)
var sql = ORM.LeftJoin<tblClass, tblStudent>("c.tblClassID = s.tblClassID")
.GetSql("where c.Mark > 0", "order by CreateDate desc", 1, 10);
--返回List
--参数1 - sql
--参数2 - 填充实体表达式
--
--最终查询(一对一)
return ORM.Get<ClassInfo, tblStudent, ClassInfo>(sql, (cls, stu) => { cls.tblStudent = stu; return cls; });
--
--最终查询(一对多)
var lookUp = new Dictionary<int?, ClassInfo>();
var list = ORM.Get<ClassInfo, tblStudent, ClassInfo>(sql,
(cls, stu) => {
ClassInfo u;
if (!lookUp.TryGetValue(cls.Id, out u))
{
lookUp.Add(cls.Id, u = cls);
}
u.tblStudent.Add(stu);
return cls;
});