Browse Source

Update Demo

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
ff4c576306
  1. 6
      Src/Asp.Net/OracleTest/Demo/Demo5_SqlQueryable.cs
  2. 37
      Src/Asp.Net/OracleTest/Demo/Demo6_Queue.cs
  3. 10
      Src/Asp.Net/OracleTest/Demo/Demo7_Ado.cs
  4. 3
      Src/Asp.Net/OracleTest/Demo/DemoE_CodeFirst.cs
  5. 2
      Src/Asp.Net/OracleTest/Demo/DemoF_Utilities.cs

6
Src/Asp.Net/OracleTest/Demo/Demo5_SqlQueryable.cs

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

37
Src/Asp.Net/OracleTest/Demo/Demo6_Queue.cs

@ -11,42 +11,7 @@ namespace OrmTest
{
public static void Init()
{
Console.WriteLine("");
Console.WriteLine("#### Queue Start ####");
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
AopEvents = new AopEvents
{
OnLogExecuting = (sql, p) =>
{
Console.WriteLine(sql);
Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
}
}
});
db.Insertable<Order>(new Order() { Name = "a" }).AddQueue();
db.Insertable<Order>(new Order() { Name = "b" }).AddQueue();
db.SaveQueues();
db.Insertable<Order>(new Order() { Name = "a" }).AddQueue();
db.Insertable<Order>(new Order() { Name = "b" }).AddQueue();
db.Insertable<Order>(new Order() { Name = "c" }).AddQueue();
db.Insertable<Order>(new Order() { Name = "d" }).AddQueue();
var ar = db.SaveQueuesAsync();
ar.Wait();
db.Queryable<Order>().AddQueue();
db.Queryable<Order>().AddQueue();
db.AddQueue("select * from [Order] where id=@id", new { id = 10000 });
var result2 = db.SaveQueues<Order, Order, Order>();
Console.WriteLine("#### Queue End ####");
//NoSupport
}
}
}

10
Src/Asp.Net/OracleTest/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 [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 \"ORDER\" where id>1000");
//db.Ado.xxx
Console.WriteLine("#### Ado End ####");
}

3
Src/Asp.Net/OracleTest/Demo/DemoE_CodeFirst.cs

@ -28,10 +28,9 @@ namespace OrmTest
public class CodeFirstTable1
{
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
[SugarColumn(OracleSequenceName ="SEQ_ID", IsPrimaryKey = true)]
public int Id { get; set; }
public string Name { get; set; }
[SugarColumn(ColumnDataType = "Nvarchar(255)")]//custom
public string Text { get; set; }
[SugarColumn(IsNullable = true)]
public DateTime CreateTime { get; set; }

2
Src/Asp.Net/OracleTest/Demo/DemoF_Utilities.cs

@ -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 ####");

Loading…
Cancel
Save