Browse Source

Update demo

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
4ea9b897e2
  1. 146
      Src/Asp.Net/OracleTest/Demo/Demo0_SqlSugarClient.cs
  2. 8
      Src/Asp.Net/OracleTest/Demo/Demo1_Queryable.cs
  3. 6
      Src/Asp.Net/OracleTest/Demo/Demo2_Updateable.cs
  4. 2
      Src/Asp.Net/OracleTest/Demo/Demo3_Insertable.cs
  5. 2
      Src/Asp.Net/OracleTest/Demo/Demo4_Deleteable.cs
  6. 2
      Src/Asp.Net/OracleTest/Demo/Demo5_SqlQueryable.cs
  7. 2
      Src/Asp.Net/OracleTest/Demo/Demo6_Queue.cs
  8. 2
      Src/Asp.Net/OracleTest/Demo/Demo7_Ado.cs
  9. 2
      Src/Asp.Net/OracleTest/Demo/Demo8_Saveable.cs
  10. 2
      Src/Asp.Net/OracleTest/Demo/Demo9_EntityMain.cs
  11. 2
      Src/Asp.Net/OracleTest/Demo/DemoA_DbMain.cs
  12. 2
      Src/Asp.Net/OracleTest/Demo/DemoB_Aop.cs
  13. 2
      Src/Asp.Net/OracleTest/Demo/DemoD_DbFirst.cs
  14. 3
      Src/Asp.Net/OracleTest/Demo/DemoE_CodeFirst.cs
  15. 2
      Src/Asp.Net/OracleTest/Demo/DemoF_Utilities.cs
  16. 2
      Src/Asp.Net/OracleTest/Demo/DemoG_SimpleClient.cs
  17. 2
      Src/Asp.Net/OracleTest/Demo/Democ_GobalFilter.cs
  18. 6
      Src/Asp.Net/OracleTest/Models/Mapper.cs
  19. 2
      Src/Asp.Net/OracleTest/Models/Order.cs
  20. 2
      Src/Asp.Net/OracleTest/Models/OrderItem.cs
  21. 2
      Src/Asp.Net/OracleTest/OldTest/Demos/7_Filter.cs
  22. 2
      Src/Asp.Net/OracleTest/OldTest/PerformanceTesting/SqlSugarPerformance.cs
  23. 4
      Src/Asp.Net/OracleTest/OldTest/UnitTest/Mapping .cs
  24. 2
      Src/Asp.Net/OracleTest/OldTest/UnitTest/Query/JoinQuery.cs
  25. 2
      Src/Asp.Net/OracleTest/OldTest/UnitTest/UnitTestBase.cs
  26. 5
      Src/Asp.Net/OracleTest/UnitTest/Main.cs
  27. 8
      Src/Asp.Net/OracleTest/UnitTest/UThread.cs
  28. 8
      Src/Asp.Net/OracleTest/UnitTest/Updateable.cs
  29. 4
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs
  30. 4
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs
  31. 2
      Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs
  32. 1
      Src/Asp.Net/SqlSugar/Realization/Oracle/OracleProvider.cs

146
Src/Asp.Net/OracleTest/Demo/Demo0_SqlSugarClient.cs

@ -17,7 +17,6 @@ namespace OrmTest
SqlSugarClient();//Create db
DbContext();//Optimizing SqlSugarClient usage
SingletonPattern();//Singleten Pattern
DistributedTransactionExample();
MasterSlave();//Read-write separation
CustomAttribute();
}
@ -29,7 +28,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = Config.ConnectionString,//Master Connection
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
SlaveConnectionConfigs = new List<SlaveConnectionConfig>() {
@ -37,6 +36,7 @@ namespace OrmTest
new SlaveConnectionConfig() { HitRate=10, ConnectionString=Config.ConnectionString2 }
}
});
db.Aop.OnLogExecuted = (s, p) =>
{
Console.WriteLine(db.Ado.Connection.ConnectionString);
@ -54,7 +54,7 @@ namespace OrmTest
Console.WriteLine("#### SqlSugarClient Start ####");
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
@ -68,11 +68,17 @@ namespace OrmTest
}
});
//If no exist create datebase
db.DbMaintenance.CreateDatabase();
var isAnySeq = db.Ado.GetInt("SELECT COUNT(*) FROM USER_SEQUENCES WHERE SEQUENCE_NAME = 'SEQ_ID'") >0;
//Create seq 相当于创建一个自增标识
if (!isAnySeq)
{
db.Ado.ExecuteCommand("CREATE SEQUENCE Seq_Id");
}
//Use db query
var dt = db.Ado.GetDataTable("select 1");
var dt = db.Ado.GetDataTable("select 1 from dual");
//Create tables
db.CodeFirst.InitTables(typeof(OrderItem),typeof(Order));
@ -147,7 +153,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = Config.ConnectionString,
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute,
ConfigureExternalServices = new ConfigureExternalServices()
@ -210,7 +216,7 @@ namespace OrmTest
new ConnectionConfig()
{
ConfigId = 1,
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
@ -219,126 +225,6 @@ namespace OrmTest
OnLogExecuting = (sql, p) => { Console.WriteLine(sql); }
}
});
private static void DistributedTransactionExample()
{
Console.WriteLine("");
Console.WriteLine("#### Distributed TransactionExample Start ####");
SqlSugarClient db = new SqlSugarClient(new List<ConnectionConfig>()
{
new ConnectionConfig(){ ConfigId="1", DbType=DbType.SqlServer, ConnectionString=Config.ConnectionString,InitKeyType=InitKeyType.Attribute,IsAutoCloseConnection=true },
new ConnectionConfig(){ ConfigId="2", DbType=DbType.SqlServer, ConnectionString=Config.ConnectionString2 ,InitKeyType=InitKeyType.Attribute ,IsAutoCloseConnection=true}
});
//use db1
db.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(Order), typeof(OrderItem));//
db.Insertable(new Order() { Name = "order1", CreateTime = DateTime.Now }).ExecuteCommand();
Console.WriteLine(db.CurrentConnectionConfig.DbType + ":" + db.Queryable<Order>().Count());
//use db2
db.ChangeDatabase("2");
db.DbMaintenance.CreateDatabase();//Create Database2
db.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(Order), typeof(OrderItem));
db.Insertable(new Order() { Name = "order1", CreateTime = DateTime.Now }).ExecuteCommand();
Console.WriteLine(db.CurrentConnectionConfig.DbType + ":" + db.Queryable<Order>().Count());
// Example 1
Console.WriteLine("Example 1");
try
{
db.BeginTran();
db.ChangeDatabase("1");//use db1
db.Deleteable<Order>().ExecuteCommand();
Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
db.ChangeDatabase("2");//use db2
db.Deleteable<Order>().ExecuteCommand();
Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
throw new Exception();
db.CommitTran();
}
catch
{
db.RollbackTran();
Console.WriteLine("---Roll back");
db.ChangeDatabase("1");//use db1
Console.WriteLine(db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
db.ChangeDatabase("2");//use db2
Console.WriteLine(db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
}
// Example 2
Console.WriteLine("Example 2");
var result=db.UseTran(() =>
{
db.ChangeDatabase("1");//use db1
db.Deleteable<Order>().ExecuteCommand();
Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
db.ChangeDatabase("2");//use db2
db.Deleteable<Order>().ExecuteCommand();
Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
throw new Exception("");
});
if (result.IsSuccess == false) {
Console.WriteLine("---Roll back");
db.ChangeDatabase("1");//use db1
Console.WriteLine(db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
db.ChangeDatabase("2");//use db2
Console.WriteLine(db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
}
// Example 3
Console.WriteLine("Example 3");
var result2 = db.UseTranAsync(() =>
{
db.ChangeDatabase("1");//use db1
db.Deleteable<Order>().ExecuteCommand();
Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
db.ChangeDatabase("2");//use db2
db.Deleteable<Order>().ExecuteCommand();
Console.WriteLine("---Delete all " + db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
throw new Exception("");
});
result2.Wait();
if (result.IsSuccess == false)
{
Console.WriteLine("---Roll back");
db.ChangeDatabase("1");//use sqlserver
Console.WriteLine(db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
db.ChangeDatabase("2");//use mysql
Console.WriteLine(db.CurrentConnectionConfig.DbType);
Console.WriteLine(db.Queryable<Order>().Count());
}
Console.WriteLine("#### Distributed TransactionExample End ####");
}
}
/// <summary>
@ -353,7 +239,7 @@ namespace OrmTest
Db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = Config.ConnectionString,
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute,
AopEvents = new AopEvents()
@ -387,7 +273,7 @@ namespace OrmTest
Db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = Config.ConnectionString,
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute,
AopEvents = new AopEvents()

8
Src/Asp.Net/OracleTest/Demo/Demo1_Queryable.cs

@ -171,7 +171,7 @@ namespace OrmTest
.Mapper(it => it.B, it => it.BId).ToList();
//Manual mode
var result = db.Queryable<OrderInfo>().Take(10).Select<ViewOrder>().Mapper((itemModel, cache) =>
var result = db.Queryable<OrderInfo>().Select<ViewOrder>().Mapper((itemModel, cache) =>
{
var allItems = cache.Get(orderList => {
var allIds = orderList.Select(it => it.Id).ToList();
@ -189,7 +189,7 @@ 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();
Console.WriteLine("#### No Entity End ####");
@ -252,7 +252,7 @@ namespace OrmTest
//id=@id
var list4 = db.Queryable<Order>().Where("id=@id", new { id = 1 }).ToList();
//id=@id or name like '%'+@name+'%'
var list5 = db.Queryable<Order>().Where("id=@id or name like '%'+@name+'%' ", new { id = 1, name = "jack" }).ToList();
var list5 = db.Queryable<Order>().Where("id=@id or name like @name", new { id = 1, name = "%jack%" }).ToList();
@ -323,7 +323,7 @@ namespace OrmTest
{
return new SqlSugarClient(new ConnectionConfig()
{
DbType = SqlSugar.DbType.SqlServer,
DbType = SqlSugar.DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,

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

@ -16,7 +16,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
@ -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();

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

@ -16,7 +16,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,

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

@ -16,7 +16,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,

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

@ -16,7 +16,7 @@ namespace OrmTest
Console.WriteLine("#### SqlQueryable Start ####");
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true

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

@ -16,7 +16,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,

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

@ -16,7 +16,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,

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

@ -16,7 +16,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,

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

@ -16,7 +16,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,

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

@ -16,7 +16,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,

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

@ -16,7 +16,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true

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

@ -14,7 +14,7 @@ namespace OrmTest
Console.WriteLine("#### DbFirst Start ####");
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true

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

@ -14,12 +14,11 @@ namespace OrmTest
Console.WriteLine("#### CodeFirst Start ####");
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString3,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true
});
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.Net/OracleTest/Demo/DemoF_Utilities.cs

@ -16,7 +16,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,

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

@ -16,7 +16,7 @@ namespace OrmTest
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,

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

@ -38,7 +38,7 @@ namespace OrmTest
public static SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { DbType = DbType.SqlServer, ConnectionString = Config.ConnectionString, IsAutoCloseConnection = true });
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { DbType = DbType.Oracle, ConnectionString = Config.ConnectionString, IsAutoCloseConnection = true });
//single table query gobal filter
db.QueryFilter.Add(new SqlFilterItem()

6
Src/Asp.Net/OracleTest/Models/Mapper.cs

@ -30,7 +30,7 @@ namespace OrmTest
}
public class ABMapping
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
[SugarColumn(IsPrimaryKey = true,OracleSequenceName = "SEQ_ID")]
public int AId { get; set; }
public int BId { get; set; }
[SugarColumn(IsIgnore = true)]
@ -41,13 +41,13 @@ namespace OrmTest
}
public class A
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
[SugarColumn(IsPrimaryKey = true, OracleSequenceName ="SEQ_ID")]
public int Id { get; set; }
public string Name { get; set; }
}
public class B
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
[SugarColumn(IsPrimaryKey = true, OracleSequenceName = "SEQ_ID")]
public int Id { get; set; }
public string Name { get; set; }
}

2
Src/Asp.Net/OracleTest/Models/Order.cs

@ -9,7 +9,7 @@ namespace OrmTest
public class Order
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
[SugarColumn(IsPrimaryKey = true, OracleSequenceName ="Seq_Id")]
public int Id { get; set; }
public string Name { get; set; }

2
Src/Asp.Net/OracleTest/Models/OrderItem.cs

@ -8,7 +8,7 @@ namespace OrmTest
[SqlSugar.SugarTable("OrderDetail")]
public class OrderItem
{
[SqlSugar.SugarColumn(IsPrimaryKey =true, IsIdentity =true)]
[SqlSugar.SugarColumn(IsPrimaryKey =true, OracleSequenceName = "Seq_Id")]
public int ItemId { get; set; }
public int OrderId { get; set; }
public decimal? Price { get; set; }

2
Src/Asp.Net/OracleTest/OldTest/Demos/7_Filter.cs

@ -39,7 +39,7 @@ namespace OrmTest.Demo
public static SqlSugarClient GetInstance1()
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.Oracle, IsAutoCloseConnection = true });
db.QueryFilter
.Add(new SqlFilterItem()
{

2
Src/Asp.Net/OracleTest/OldTest/PerformanceTesting/SqlSugarPerformance.cs

@ -19,7 +19,7 @@ namespace OrmTest.PerformanceTesting
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = Config.ConnectionString,
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
IsAutoCloseConnection = false
});
db.IgnoreColumns.Add("TestId", "Student");

4
Src/Asp.Net/OracleTest/OldTest/UnitTest/Mapping .cs

@ -51,12 +51,12 @@ namespace OrmTest.UnitTest
public new SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { InitKeyType = InitKeyType.Attribute, ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { InitKeyType = InitKeyType.Attribute, ConnectionString = Config.ConnectionString, DbType = DbType.Oracle, IsAutoCloseConnection = true });
return db;
}
public SqlSugarClient GetInstance2()
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { InitKeyType = InitKeyType.Attribute, ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { InitKeyType = InitKeyType.Attribute, ConnectionString = Config.ConnectionString, DbType = DbType.Oracle, IsAutoCloseConnection = true });
db.Aop.OnLogExecuting = (sql, pars) =>
{
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars));

2
Src/Asp.Net/OracleTest/OldTest/UnitTest/Query/JoinQuery.cs

@ -128,7 +128,7 @@ namespace OrmTest.UnitTest
public new SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.Oracle });
db.Aop.OnLogExecuting = (sql, pars) =>
{
Console.WriteLine(sql + " " + pars);

2
Src/Asp.Net/OracleTest/OldTest/UnitTest/UnitTestBase.cs

@ -48,7 +48,7 @@ namespace OrmTest.UnitTest
public SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.Oracle, IsAutoCloseConnection = true });
return db;
}
}

5
Src/Asp.Net/OracleTest/UnitTest/Main.cs

@ -10,7 +10,7 @@ namespace OrmTest
{
public static SqlSugarClient Db=> new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
@ -28,6 +28,9 @@ namespace OrmTest
{
Db.DbMaintenance.TruncateTable<Order>();
Db.DbMaintenance.TruncateTable<OrderItem>();
Db.DbMaintenance.TruncateTable<A>();
Db.DbMaintenance.TruncateTable<B>();
Db.DbMaintenance.TruncateTable<ABMapping>();
}
public static void Init()
{

8
Src/Asp.Net/OracleTest/UnitTest/UThread.cs

@ -12,7 +12,7 @@ namespace OrmTest
public static SqlSugarClient simpleDb => new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
@ -27,7 +27,7 @@ namespace OrmTest
});
public static SqlSugarClient ssDb => new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
@ -43,7 +43,7 @@ namespace OrmTest
});
public static SqlSugarClient singleDb = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
@ -58,7 +58,7 @@ namespace OrmTest
});
public static SqlSugarClient singleAndSsDb = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
DbType = DbType.Oracle,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,

8
Src/Asp.Net/OracleTest/UnitTest/Updateable.cs

@ -43,16 +43,16 @@ namespace OrmTest
{
IsRemind = saveDiary.IsRemind,
}).Where(it => it.ID == saveDiary.ID).ToSql();
UValidate.Check(sql.Key, @"UPDATE [Diary] SET
[IsRemind] = @Const0 WHERE ( [ID] = @ID1 )", "Updateable");
UValidate.Check(sql.Key, @"UPDATE ""DIARY"" SET
""ISREMIND"" = @Const0 WHERE ( ""ID"" = @ID1 )", "Updateable");
sql = Db.Updateable<UnitDiary>().SetColumns(it => new UnitDiary()
{
TypeID = saveDiary.TypeID,
}).Where(it => it.ID == saveDiary.ID).ToSql();
UValidate.Check(sql.Key, @"UPDATE [Diary] SET
[TypeID] = @Const0 WHERE ( [ID] = @ID1 )", "Updateable");
UValidate.Check(sql.Key, @"UPDATE ""DIARY"" SET
""TYPEID"" = @Const0 WHERE ( ""ID"" = @ID1 )", "Updateable");
}
}

4
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs

@ -45,6 +45,10 @@ namespace SqlSugar
var regex = @"^AND (\@Const\d+) $";
if (this.Context is OracleExpressionContext)
{
regex = @"^AND (\:Const\d+) $";
}
if (Regex.IsMatch(result, regex))
{
result = "AND " + this.Context.Parameters.First(it => it.ParameterName == Regex.Match(result, regex).Groups[1].Value).Value;

4
Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs

@ -45,6 +45,10 @@ namespace SqlSugar
var regex = @"^WHERE (\@Const\d+) $";
if (this.Context is OracleExpressionContext)
{
regex = @"^WHERE (\:Const\d+) $";
}
if (Regex.IsMatch(result, regex))
{
result = "WHERE " + this.Context.Parameters.First(it => it.ParameterName == Regex.Match(result, regex).Groups[1].Value).Value;

2
Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs

@ -357,7 +357,7 @@ namespace SqlSugar
private List<DbColumnInfo> GetColumnInfosByTableName(string tableName)
{
string sql = "select * from " + tableName + " WHERE 1=2 ";
string sql = "select * from " +SqlBuilder.GetTranslationTableName(tableName) + " WHERE 1=2 ";
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
this.Context.Ado.IsEnableLogEvent = false;
using (DbDataReader reader = (DbDataReader)this.Context.Ado.GetDataReader(sql))

1
Src/Asp.Net/SqlSugar/Realization/Oracle/OracleProvider.cs

@ -16,6 +16,7 @@ namespace SqlSugar
{
this.FormatSql = sql =>
{
sql = sql.Replace("+@", "+:");
if (sql.HasValue()&&sql.Contains("@")) {
var exceptionalCaseInfo = Regex.Matches(sql, @"\'.*?\@.*?\'| [\.,\w]+\@[\.,\w]+ | [\.,\w]+\@[\.,\w]+");
if (exceptionalCaseInfo != null) {

Loading…
Cancel
Save