mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
51 lines
1.1 KiB
C#
51 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using SqlSugar;
|
|
using OrmTest.Demo;
|
|
|
|
namespace OrmTest.Demo
|
|
{
|
|
public class ComplexModel : DemoBase
|
|
{
|
|
public static void Init()
|
|
{
|
|
var db = GetInstance();
|
|
var student = db.Queryable<CMStudent>().ToList();
|
|
}
|
|
}
|
|
|
|
[SugarTable("Student")]
|
|
public class CMStudent : ModelContext
|
|
{
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
public int SchoolId { get; set; }
|
|
|
|
[SugarColumn(IsIgnore = true)]
|
|
public CMSchool SchoolSingle
|
|
{
|
|
get
|
|
{
|
|
return base.CreateMapping<CMSchool>().Single(it => it.Id == this.Id);
|
|
}
|
|
}
|
|
|
|
[SugarColumn(IsIgnore = true)]
|
|
public List<CMSchool> SchoolList
|
|
{
|
|
get
|
|
{
|
|
return base.CreateMapping<CMSchool>().Where(it => it.Id == this.Id).ToList();
|
|
}
|
|
}
|
|
}
|
|
|
|
[SugarTable("School")]
|
|
public class CMSchool
|
|
{
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
}
|
|
} |