mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 16:18:47 +08:00
Oracle SqlTest supports @
This commit is contained in:
parent
7c3094e624
commit
cb6289e272
@ -26,6 +26,13 @@ namespace OrmTest.Demo
|
|||||||
//StoredProcedure();
|
//StoredProcedure();
|
||||||
Enum();
|
Enum();
|
||||||
Simple();
|
Simple();
|
||||||
|
SqlTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SqlTest()
|
||||||
|
{
|
||||||
|
var db = GetInstance();
|
||||||
|
var x = db.Ado.ExecuteCommand("select '@id' as id from student where id=@id",new { id=1});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Simple()
|
private static void Simple()
|
||||||
|
@ -64,7 +64,7 @@ namespace OrmTest.Demo
|
|||||||
t12.Wait();
|
t12.Wait();
|
||||||
|
|
||||||
//update one columns
|
//update one columns
|
||||||
var count = db.Updateable<Student>().UpdateColumns(it => it.SchoolId == 1).Where(it => it.Id == 1).ExecuteCommand();
|
var count = db.Updateable<Student>().UpdateColumns(it => it.SchoolId == it.SchoolId+1).Where(it => it.Id == it.Id+1).ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ namespace SqlSugar
|
|||||||
public virtual Action<string, SugarParameter[]> LogEventStarting { get; set; }
|
public virtual Action<string, SugarParameter[]> LogEventStarting { get; set; }
|
||||||
public virtual Action<string, SugarParameter[]> LogEventCompleted { get; set; }
|
public virtual Action<string, SugarParameter[]> LogEventCompleted { get; set; }
|
||||||
public virtual Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> ProcessingEventStartingSQL { get; set; }
|
public virtual Func<string, SugarParameter[], KeyValuePair<string, SugarParameter[]>> ProcessingEventStartingSQL { get; set; }
|
||||||
|
protected virtual Func<string,string> FormatSql { get; set; }
|
||||||
public virtual Action<Exception> ErrorEvent { get; set; }
|
public virtual Action<Exception> ErrorEvent { get; set; }
|
||||||
public virtual List<IDbConnection> SlaveConnections { get; set; }
|
public virtual List<IDbConnection> SlaveConnections { get; set; }
|
||||||
public virtual IDbConnection MasterConnection { get; set; }
|
public virtual IDbConnection MasterConnection { get; set; }
|
||||||
@ -254,6 +255,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (FormatSql != null)
|
||||||
|
sql = FormatSql(sql);
|
||||||
SetConnectionStart(sql);
|
SetConnectionStart(sql);
|
||||||
if (this.ProcessingEventStartingSQL != null)
|
if (this.ProcessingEventStartingSQL != null)
|
||||||
ExecuteProcessingSQL(ref sql, parameters);
|
ExecuteProcessingSQL(ref sql, parameters);
|
||||||
@ -281,6 +284,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (FormatSql != null)
|
||||||
|
sql = FormatSql(sql);
|
||||||
SetConnectionStart(sql);
|
SetConnectionStart(sql);
|
||||||
var isSp = this.CommandType == CommandType.StoredProcedure;
|
var isSp = this.CommandType == CommandType.StoredProcedure;
|
||||||
if (this.ProcessingEventStartingSQL != null)
|
if (this.ProcessingEventStartingSQL != null)
|
||||||
@ -307,6 +312,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (FormatSql != null)
|
||||||
|
sql = FormatSql(sql);
|
||||||
SetConnectionStart(sql);
|
SetConnectionStart(sql);
|
||||||
if (this.ProcessingEventStartingSQL != null)
|
if (this.ProcessingEventStartingSQL != null)
|
||||||
ExecuteProcessingSQL(ref sql, parameters);
|
ExecuteProcessingSQL(ref sql, parameters);
|
||||||
@ -337,6 +344,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (FormatSql != null)
|
||||||
|
sql = FormatSql(sql);
|
||||||
SetConnectionStart(sql);
|
SetConnectionStart(sql);
|
||||||
if (this.ProcessingEventStartingSQL != null)
|
if (this.ProcessingEventStartingSQL != null)
|
||||||
ExecuteProcessingSQL(ref sql, parameters);
|
ExecuteProcessingSQL(ref sql, parameters);
|
||||||
|
@ -5,12 +5,30 @@ using System.Data;
|
|||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class OracleProvider : AdoProvider
|
public class OracleProvider : AdoProvider
|
||||||
{
|
{
|
||||||
public OracleProvider() { }
|
public OracleProvider()
|
||||||
|
{
|
||||||
|
this.FormatSql = sql =>
|
||||||
|
{
|
||||||
|
if (sql.HasValue()&&sql.Contains("@")) {
|
||||||
|
var exceptionalCaseInfo = Regex.Matches(sql,@"\'.*?\@.*?\'");
|
||||||
|
if (exceptionalCaseInfo != null) {
|
||||||
|
foreach (var item in exceptionalCaseInfo.Cast<Match>())
|
||||||
|
{
|
||||||
|
sql = sql.Replace(item.Value, item.Value.Replace("@", UtilConstants.ReplaceKey));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sql = sql .Replace("@",":");
|
||||||
|
sql = sql.Replace(UtilConstants.ReplaceKey, "@");
|
||||||
|
}
|
||||||
|
return sql;
|
||||||
|
};
|
||||||
|
}
|
||||||
public override string SqlParameterKeyWord
|
public override string SqlParameterKeyWord
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
Loading…
Reference in New Issue
Block a user