This commit is contained in:
sunkaixuan 2022-11-10 14:43:28 +08:00
parent 9a8660c315
commit d1e7617df7

View File

@ -8,7 +8,7 @@ namespace OrmTest
{
public class Unit01
{
public static void Init()
public static void Init()
{
var client = new SqlSugarClient(new ConnectionConfig()
{
@ -29,6 +29,27 @@ namespace OrmTest
client.Queryable<TestUserEntity>().Where(u => u.cate.Equals("a")).ToList();
client.Queryable<TestUserEntity>().Where(u => u.cate.Equals(users[0].cate)).ToList();
client.CodeFirst.InitTables<UnitPage>();
if (!client.Queryable<UnitPage>().Any())
{
client.Insertable(new UnitPage() { id = 1 }).ExecuteCommand();
client.Insertable(new UnitPage() { id = 2 }).ExecuteCommand();
client.Insertable(new UnitPage() { id = 3 }).ExecuteCommand();
client.Insertable(new UnitPage() { id = 4 }).ExecuteCommand();
client.Insertable(new UnitPage() { id = 4 }).ExecuteCommand();
client.Insertable(new UnitPage() { id = 6 }).ExecuteCommand();
client.Insertable(new UnitPage() { id = 7 }).ExecuteCommand();
}
var first = client.Queryable<UnitPage>().Take(1).ToList();
var first2 = client.Queryable<UnitPage>().First();
var pagr1 = client.Queryable<UnitPage>().ToPageList(1, 2);
var pagr2 = client.Queryable<UnitPage>().ToPageList(2, 2);
var pagr3 = client.Queryable<UnitPage>().ToPageList(0, 2);
}
public class UnitPage
{
public int id { get; set; }
}
[SugarTable("TestUser")]