using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OrmTest { public partial class NewUnitTest { public static void CodeFirst() { if (Db.DbMaintenance.IsAnyTable("UnitCodeTest1", false)) Db.DbMaintenance.DropTable("UnitCodeTest1"); Db.CodeFirst.InitTables(); Db.CodeFirst.InitTables(); var db = Db; db.CurrentConnectionConfig.MoreSettings = new ConnMoreSettings() { PgSqlIsAutoToLower = false, PgSqlIsAutoToLowerCodeFirst = false }; db.CodeFirst.InitTables(); var list = db.Queryable().LeftJoin((X1, Y1) => X1.Id == Y1.Id) .Where(X1 => X1.Id == 1) .Select(X1 => new { x1 = X1.Id, x2 = X1.Name }).ToList(); var list2 = db.Queryable().LeftJoin((X1, Y1) => X1.Id == Y1.Id) .Where(X1 => X1.Id == 1) .Select().ToList(); } public class VUpperOrder { [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } public DateTime UpperItemCreateTime { get; set; } public int UpperItemCustomId { get; set; } } public class UpperOrder { [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } [SugarColumn(IsNullable = true)] public DateTime CreateTime { get; set; } [SugarColumn(IsNullable = true)] public int CustomId { get; set; } [SugarColumn(IsIgnore = true)] public List Items { get; set; } } public class UpperItem { [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } [SugarColumn(IsNullable = true)] public DateTime CreateTime { get; set; } [SugarColumn(IsNullable = true)] public int CustomId { get; set; } [SugarColumn(IsIgnore = true)] public List Items { get; set; } } [SqlSugar.SugarIndex("UnitIndextestIndex", nameof(UnitIndextest.Table), SqlSugar.OrderByType.Asc)] public class UnitIndextest { public string Table { get; set; } public string Id { get; set; } } public class UnitCodeTest1 { [SqlSugar.SugarColumn(IndexGroupNameList = new string[] { "group1" })] public int Id { get; set; } [SqlSugar.SugarColumn(DefaultValue= "now()", IndexGroupNameList =new string[] {"group1" } )] public DateTime? CreateDate { get; set; } } } }