Browse Source

Update GBase Demo

SqlSugar5
sunkaixuan 2 years ago
parent
commit
5b79f9badb
  1. 10
      Src/Asp.NetCore2/GbaseTest/Demo/Demo7_Ado.cs
  2. 2
      Src/Asp.NetCore2/GbaseTest/Demo/DemoE_CodeFirst.cs
  3. 2
      Src/Asp.NetCore2/GbaseTest/Program.cs

10
Src/Asp.NetCore2/GbaseTest/Demo/Demo7_Ado.cs

@ -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 intValue=db.Ado.SqlQuerySingle<int>("select 1");
db.Ado.ExecuteCommand("delete from \"order\" where id>1000");
var list= db.Ado.SqlQuery<Order>("select * from order ");
var intValue=db.Ado.SqlQuerySingle<int>("select 1 from dual");
db.Ado.ExecuteCommand("delete from order where id>1000");
//db.Ado.xxx
Console.WriteLine("#### Ado End ####");
}

2
Src/Asp.NetCore2/GbaseTest/Demo/DemoE_CodeFirst.cs

@ -19,7 +19,7 @@ namespace OrmTest
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true
});
db.DbMaintenance.CreateDatabase();
//db.DbMaintenance.CreateDatabase();
db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" }).ExecuteCommand();
var list = db.Queryable<CodeFirstTable1>().ToList();

2
Src/Asp.NetCore2/GbaseTest/Program.cs

@ -12,6 +12,8 @@ namespace GbaseTest
Demo3_Insertable.Init();
Demo4_Deleteable.Init();
Demo2_Updateable.Init();
Demo7_Ado.Init();
DemoE_CodeFirst.Init();
Console.WriteLine("Hello World!");
}
}

Loading…
Cancel
Save