using SqlSugar; using System; using System.Collections.Generic; using System.Data; using System.Dynamic; using System.Linq; using System.Text; namespace OrmTest { public class UCustom22 { public static void Init() { var db = NewUnitTest.Db; //建表 if (!db.DbMaintenance.IsAnyTable("UnitTest0011", false)) { db.CodeFirst.InitTables(); } db.Insertable(new List() { new Test0011 { id = 1, age = 1 }, new Test0011 { id = 2, age = 2 } }).ExecuteCommand(); //用例代码 Search(db); db.CurrentConnectionConfig.MoreSettings = new ConnMoreSettings() { IsWithNoLockQuery=true }; db.Queryable() .Select() .MergeTable().LeftJoin((x, y) => true) .ToList(); } public static List Search(SqlSugarClient db) where T : ISearch { var searchReq = new { age = 1 }; return db.Queryable().Where(u => u.age == searchReq.age).ToList(); } //用例实体 [SugarTable("UnitTest0011")] public class Test0011 : ISearch { public int id { get; set; } public int age { get; set; } } public interface ISearch { int age { get; set; } } } }