Update demo

This commit is contained in:
sunkaixuan 2024-10-25 16:03:07 +08:00
parent a79985fa47
commit 7ba361b7c0
9 changed files with 22 additions and 23 deletions

View File

@ -16,16 +16,16 @@ namespace OrmTest
/// Account have permission to create database
/// 用有建库权限的数据库账号
/// </summary>
public static string ConnectionString = "server=localhost;Database=SqlSugar4xTest;Uid=root;Pwd=haosql; AllowLoadLocalInfile=true";
public static string ConnectionString = "server=localhost;Database=SqlSugar4xTest;Uid=root;Pwd=123456; AllowLoadLocalInfile=true";
/// <summary>
/// Account have permission to create database
/// 用有建库权限的数据库账号
/// </summary>
public static string ConnectionString2 = "server=localhost;Database=SqlSugar4xTest2;Uid=root;Pwd=haosql";
public static string ConnectionString2 = "server=localhost;Database=SqlSugar4xTest2;Uid=root;Pwd=123456";
/// <summary>
/// Account have permission to create database
/// 用有建库权限的数据库账号
/// </summary>
public static string ConnectionString3 = "server=localhost;Database=SqlSugar4xTest3;Uid=root;Pwd=haosql";
public static string ConnectionString3 = "server=localhost;Database=SqlSugar4xTest3;Uid=root;Pwd=123456";
}
}

View File

@ -140,7 +140,7 @@ namespace OrmTest
var db = GetInstance();
//Creater Table
db.CodeFirst.InitTables(typeof(Tree));
db.DbMaintenance.TruncateTable("tree");
db.DbMaintenance.TruncateTable("Tree");
db.Insertable(new Tree() { Id = 1, Name = "root" }).ExecuteCommand();
db.Insertable(new Tree() { Id = 11, Name = "child1",ParentId=1 }).ExecuteCommand();
db.Insertable(new Tree() { Id = 12, Name = "child2",ParentId=1 }).ExecuteCommand();
@ -194,9 +194,9 @@ namespace OrmTest
Console.WriteLine("#### No Entity Start ####");
var db = GetInstance();
var list = db.Queryable<dynamic>().AS("order").Where("id=id", new { id = 1 }).ToList();
var list = db.Queryable<dynamic>().AS("Order").Where("id=id", new { id = 1 }).ToList();
var list2 = db.Queryable<dynamic>("o").AS("order").AddJoinInfo("OrderDetail", "i", "o.id=i.OrderId").Where("id=id", new { id = 1 }).Select("o.*").ToList();
var list2 = db.Queryable<dynamic>("o").AS("Order").AddJoinInfo("OrderDetail", "i", "o.id=i.OrderId").Where("id=id", new { id = 1 }).Select("o.*").ToList();
Console.WriteLine("#### No Entity End ####");
}

View File

@ -78,8 +78,8 @@ namespace OrmTest
var dtList = new List<Dictionary<string, object>>();
dtList.Add(dt);
var t66 = db.Updateable(dt).AS("`order`").WhereColumns("id").ExecuteCommand();
var t666 = db.Updateable(dtList).AS("`order`").WhereColumns("id").ExecuteCommand();
var t66 = db.Updateable(dt).AS("`Order`").WhereColumns("id").ExecuteCommand();
var t666 = db.Updateable(dtList).AS("`Order`").WhereColumns("id").ExecuteCommand();

View File

@ -23,13 +23,13 @@ namespace OrmTest
});
int total = 0;
var list = db.SqlQueryable<Order>("select * from `order`").ToPageList(1, 2, ref total);
var list = db.SqlQueryable<Order>("select * from `Order`").ToPageList(1, 2, ref total);
//by expression
var list2 = db.SqlQueryable<Order>("select * from `order`").Where(it => it.Id == 1).ToPageList(1, 2);
var list2 = db.SqlQueryable<Order>("select * from `Order`").Where(it => it.Id == 1).ToPageList(1, 2);
//by sql
var list3 = db.SqlQueryable<Order>("select * from `order`").Where("id=@id", new { id = 1 }).ToPageList(1, 2);
var list3 = db.SqlQueryable<Order>("select * from `Order`").Where("id=@id", new { id = 1 }).ToPageList(1, 2);
Console.WriteLine("#### SqlQueryable End ####");
}

View File

@ -43,7 +43,7 @@ namespace OrmTest
db.Queryable<Order>().AddQueue();
db.Queryable<Order>().AddQueue();
db.AddQueue("select * from `order` where id=@id", new { id = 10000 });
db.AddQueue("select * from `Order` where id=@id", new { id = 10000 });
var result2 = db.SaveQueues<Order, Order, Order>();
Console.WriteLine("#### Queue End ####");

View File

@ -30,13 +30,13 @@ namespace OrmTest
}
});
//sql
var dt = db.Ado.GetDataTable("select * from `order` where @id>0 or name=@name", new List<SugarParameter>(){
var dt = db.Ado.GetDataTable("select * from `Order` where @id>0 or name=@name", new List<SugarParameter>(){
new SugarParameter("@id",1),
new SugarParameter("@name","2")
});
//sql
var dt2 = db.Ado.GetDataTable("select * from `order` where @id>0 or name=@name", new { id = 1, name = "2" });
var dt2 = db.Ado.GetDataTable("select * from `Order` where @id>0 or name=@name", new { id = 1, name = "2" });
//Stored Procedure
//var dt3 = db.Ado.UseStoredProcedure().GetDataTable("sp_school", new { name = "张三", age = 0 });
@ -47,9 +47,9 @@ namespace OrmTest
//There are many methods to under db.ado
var list= db.Ado.SqlQuery<Order>("select * from `order` ");
var list= db.Ado.SqlQuery<Order>("select * from `Order` ");
var intValue=db.Ado.SqlQuerySingle<int>("select 1");
db.Ado.ExecuteCommand("delete from `order` where id>1000");
db.Ado.ExecuteCommand("delete from `Order` where id>1000");
//db.Ado.xxx
Console.WriteLine("#### Ado End ####");
}

View File

@ -37,7 +37,7 @@ namespace OrmTest
Console.WriteLine(string.Join("," ,list));
});
var list2= db.Utilities.DataTableToList<Order>(db.Ado.GetDataTable("select * from `order`"));
var list2= db.Utilities.DataTableToList<Order>(db.Ado.GetDataTable("select * from `Order`"));
//more https://github.com/sunkaixuan/SqlSugar/wiki/f.Utilities
Console.WriteLine("#### Utilities End ####");

View File

@ -16,21 +16,21 @@ namespace OrmTest
var sql = db.Queryable<Order>().ToSql();
//SELECT [Id],[Name],[Price],[CreateTime] FROM `order` WHERE isDelete=0
//SELECT [Id],[Name],[Price],[CreateTime] FROM `Order` WHERE isDelete=0
Console.WriteLine(sql);
var sql2 = db.Queryable<Order,OrderItem>((main,ot)=> main.Id==ot.OrderId).ToSql();
//SELECT [Id],[Name],[Price],[CreateTime] FROM `order` main ,[OrderDetail] ot WHERE ( [main].[Id] = [ot].[OrderId] ) AND main.isDelete=0
//SELECT [Id],[Name],[Price],[CreateTime] FROM `Order` main ,[OrderDetail] ot WHERE ( [main].[Id] = [ot].[OrderId] ) AND main.isDelete=0
Console.WriteLine(sql2);
var sql3 = db.Queryable<Order>().Filter("Myfilter").ToSql();// Myfilter+Gobal
//SELECT [Id],[Name],[Price],[CreateTime] FROM `order` WHERE Name='jack' AND isDelete=0
//SELECT [Id],[Name],[Price],[CreateTime] FROM `Order` WHERE Name='jack' AND isDelete=0
Console.WriteLine(sql3);
var sql4 = db.Queryable<Order>().Filter("Myfilter",isDisabledGobalFilter:true).ToSql();//only Myfilter
//SELECT [Id],[Name],[Price],[CreateTime] FROM `order` WHERE Name='jack'
//SELECT [Id],[Name],[Price],[CreateTime] FROM `Order` WHERE Name='jack'
Console.WriteLine(sql4);
Console.WriteLine("#### Filter End ####");
}

View File

@ -6,8 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SqlSugar.MySqlConnectorCore" Version="5.9.5" />
<PackageReference Include="sqlSugarCore" Version="5.1.3.2-preview01" />
<PackageReference Include="sqlSugarCore" Version="5.1.4.170" />
</ItemGroup>
</Project>