Update ComplexModel

This commit is contained in:
sunkaixuan
2017-06-11 14:15:24 +08:00
parent 2c5f8ba4a9
commit 2b46386b98
7 changed files with 72 additions and 35 deletions

View File

@@ -12,7 +12,7 @@ namespace OrmTest.Demo
public static void Init()
{
var db = GetInstance();
var student = db.Queryable<CMStudent>().ToList();
var students = db.Queryable<CMStudent>().ToList();
}
}
@@ -23,12 +23,24 @@ namespace OrmTest.Demo
public string Name { get; set; }
public int SchoolId { get; set; }
[SugarColumn(IsIgnore = true)]
public string SchoolName
{
get
{
if (this.SchoolSingle != null)
return this.SchoolSingle.Name;
else
return null;
}
}
[SugarColumn(IsIgnore = true)]
public CMSchool SchoolSingle
{
get
{
return base.CreateMapping<CMSchool>().Single(it => it.Id == this.Id);
return base.CreateMapping<CMSchool>().Single(it => it.Id == this.SchoolId);
}
}
@@ -37,7 +49,7 @@ namespace OrmTest.Demo
{
get
{
return base.CreateMapping<CMSchool>().Where(it => it.Id == this.Id).ToList();
return base.CreateMapping<CMSchool>().Where(it => it.Id == this.SchoolId).ToList();
}
}
}