mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Update Oracle
This commit is contained in:
parent
d97e6f98be
commit
52aedd787e
@ -8,6 +8,6 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
public class Config
|
public class Config
|
||||||
{
|
{
|
||||||
public static string ConnectionString = "server=.;uid=sa;pwd=sasa;database=SqlSugar4XTest";
|
public static string ConnectionString = "Data Source=localhost/orcl;User ID=system;Password=JHL52771jhl;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace OrmTest.Demo
|
|||||||
{
|
{
|
||||||
public static SqlSugarClient GetInstance()
|
public static 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 });
|
||||||
db.Ado.IsEnableLogEvent = true;
|
db.Ado.IsEnableLogEvent = true;
|
||||||
db.Ado.LogEventStarting = (sql, pars) =>
|
db.Ado.LogEventStarting = (sql, pars) =>
|
||||||
{
|
{
|
||||||
|
@ -17,25 +17,25 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
throw new Exception(" to be continued ,It will take another week.");
|
// throw new Exception(" to be continued ,It will take another week.");
|
||||||
|
|
||||||
// /***Unit Test***/
|
// /***Unit Test***/
|
||||||
new Select(1).Init();
|
//new Select(1).Init();
|
||||||
new Field(1).Init();
|
//new Field(1).Init();
|
||||||
new Where(1).Init();
|
//new Where(1).Init();
|
||||||
new Method(1).Init();
|
//new Method(1).Init();
|
||||||
new JoinQuery(1).Init();
|
//new JoinQuery(1).Init();
|
||||||
new SingleQuery(1).Init();
|
//new SingleQuery(1).Init();
|
||||||
new SelectQuery(1).Init();
|
//new SelectQuery(1).Init();
|
||||||
new AutoClose(1).Init();
|
//new AutoClose(1).Init();
|
||||||
new Insert(1).Init();
|
//new Insert(1).Init();
|
||||||
new Delete(1).Init();
|
//new Delete(1).Init();
|
||||||
new Update(1).Init();
|
//new Update(1).Init();
|
||||||
new Mapping(1).Init();
|
//new Mapping(1).Init();
|
||||||
new DataTest(1).Init();
|
//new DataTest(1).Init();
|
||||||
new EnumTest(1).Init();
|
//new EnumTest(1).Init();
|
||||||
/***Performance Test***/
|
///***Performance Test***/
|
||||||
new SqlSugarPerformance(100).Select();
|
//new SqlSugarPerformance(100).Select();
|
||||||
|
|
||||||
/***Demo***/
|
/***Demo***/
|
||||||
OrmTest.Demo.Query.Init();
|
OrmTest.Demo.Query.Init();
|
||||||
|
@ -143,7 +143,15 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
dbTypeName = dbTypeName.ToLower();
|
dbTypeName = dbTypeName.ToLower();
|
||||||
var propertyTypes = MappingTypes.Where(it => it.Key == dbTypeName);
|
var propertyTypes = MappingTypes.Where(it => it.Key == dbTypeName);
|
||||||
if (propertyTypes == null)
|
if (dbTypeName == "int32")
|
||||||
|
{
|
||||||
|
return "int";
|
||||||
|
}
|
||||||
|
else if (dbTypeName == "int64")
|
||||||
|
{
|
||||||
|
return "long";
|
||||||
|
}
|
||||||
|
else if (propertyTypes == null)
|
||||||
{
|
{
|
||||||
return "other";
|
return "other";
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,6 @@ namespace SqlSugar
|
|||||||
public const string MySql = "MySql";
|
public const string MySql = "MySql";
|
||||||
public const string SqlServer = "SqlServer";
|
public const string SqlServer = "SqlServer";
|
||||||
public const string Sqlite = "Sqlite";
|
public const string Sqlite = "Sqlite";
|
||||||
|
public const string Oracle = "Oracle";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,16 +84,19 @@ namespace SqlSugar
|
|||||||
if (parameter.Value == null) parameter.Value = DBNull.Value;
|
if (parameter.Value == null) parameter.Value = DBNull.Value;
|
||||||
var sqlParameter = new OracleParameter();
|
var sqlParameter = new OracleParameter();
|
||||||
sqlParameter.ParameterName = parameter.ParameterName.ToLower();
|
sqlParameter.ParameterName = parameter.ParameterName.ToLower();
|
||||||
if (sqlParameter.ParameterName[0] == '@') {
|
if (sqlParameter.ParameterName[0] == '@')
|
||||||
|
{
|
||||||
sqlParameter.ParameterName = ':' + sqlParameter.ParameterName.Substring(1, sqlParameter.ParameterName.Length - 1);
|
sqlParameter.ParameterName = ':' + sqlParameter.ParameterName.Substring(1, sqlParameter.ParameterName.Length - 1);
|
||||||
}
|
}
|
||||||
//sqlParameter.UdtTypeName = parameter.UdtTypeName;
|
//sqlParameter.UdtTypeName = parameter.UdtTypeName;
|
||||||
sqlParameter.Size = parameter.Size;
|
sqlParameter.Size = parameter.Size;
|
||||||
sqlParameter.Value = parameter.Value;
|
sqlParameter.Value = parameter.Value;
|
||||||
sqlParameter.DbType = parameter.DbType;
|
sqlParameter.DbType = parameter.DbType;
|
||||||
sqlParameter.Direction = parameter.Direction;
|
if (parameter.Direction != 0)
|
||||||
|
sqlParameter.Direction = parameter.Direction;
|
||||||
result[index] = sqlParameter;
|
result[index] = sqlParameter;
|
||||||
if (sqlParameter.Direction == ParameterDirection.Output) {
|
if (sqlParameter.Direction == ParameterDirection.Output)
|
||||||
|
{
|
||||||
if (this.OutputParameters == null) this.OutputParameters = new List<IDataParameter>();
|
if (this.OutputParameters == null) this.OutputParameters = new List<IDataParameter>();
|
||||||
this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName);
|
this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName);
|
||||||
this.OutputParameters.Add(sqlParameter);
|
this.OutputParameters.Add(sqlParameter);
|
||||||
|
@ -11,5 +11,21 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public override string SqlTranslationLeft { get { return "\""; } }
|
public override string SqlTranslationLeft { get { return "\""; } }
|
||||||
public override string SqlTranslationRight { get { return "\""; } }
|
public override string SqlTranslationRight { get { return "\""; } }
|
||||||
|
public override string GetTranslationTableName(string name)
|
||||||
|
{
|
||||||
|
var result= base.GetTranslationTableName(name);
|
||||||
|
return result.ToUpper();
|
||||||
|
}
|
||||||
|
public override string GetTranslationColumnName(string entityName, string propertyName)
|
||||||
|
{
|
||||||
|
var result = base.GetTranslationColumnName(entityName, propertyName);
|
||||||
|
return result.ToUpper();
|
||||||
|
}
|
||||||
|
public override string GetTranslationColumnName(string propertyName)
|
||||||
|
{
|
||||||
|
var result = base.GetTranslationColumnName(propertyName);
|
||||||
|
return result.ToUpper();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,52 +14,22 @@ namespace SqlSugar
|
|||||||
public SqlSugarClient Context { get; set; }
|
public SqlSugarClient Context { get; set; }
|
||||||
public OracleExpressionContext()
|
public OracleExpressionContext()
|
||||||
{
|
{
|
||||||
base.DbMehtods = new OracleMethod();
|
base.DbMehtods = new MySqlMethod();
|
||||||
base.Result.IsUpper = true;
|
|
||||||
}
|
}
|
||||||
|
public override string SqlTranslationLeft { get { return "\""; } }
|
||||||
|
public override string SqlTranslationRight { get { return "\""; } }
|
||||||
public override string GetTranslationTableName(string entityName, bool isMapping = true)
|
public override string GetTranslationTableName(string entityName, bool isMapping = true)
|
||||||
{
|
{
|
||||||
Check.ArgumentNullException(entityName, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
|
return base.GetTranslationTableName(entityName, isMapping).ToUpper();
|
||||||
if (IsTranslationText(entityName)) return entityName;
|
|
||||||
if (isMapping && this.MappingTables.IsValuable())
|
|
||||||
{
|
|
||||||
if (entityName.Contains("."))
|
|
||||||
{
|
|
||||||
var columnInfo = entityName.Split('.');
|
|
||||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(columnInfo.Last(), StringComparison.CurrentCultureIgnoreCase));
|
|
||||||
if (mappingInfo != null)
|
|
||||||
{
|
|
||||||
columnInfo[columnInfo.Length - 1] = mappingInfo.EntityName;
|
|
||||||
}
|
|
||||||
return string.Join(".", columnInfo.Select(it => GetTranslationText(it)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
|
|
||||||
return "\"" + (mappingInfo == null ? entityName : mappingInfo.EntityName) + "\"";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (entityName.Contains("."))
|
|
||||||
{
|
|
||||||
return string.Join(".", entityName.Split('.').Select(it => GetTranslationText(it)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return GetTranslationText(entityName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public override bool IsTranslationText(string name)
|
public override string GetTranslationColumnName(string columnName)
|
||||||
{
|
{
|
||||||
return name.Contains("\"") && name.Contains("\"");
|
return base.GetTranslationColumnName(columnName).ToUpper();
|
||||||
}
|
}
|
||||||
public override string GetTranslationText(string name)
|
public override string GetDbColumnName(string entityName, string propertyName)
|
||||||
{
|
{
|
||||||
return "\"" + name + "\"";
|
return base.GetDbColumnName(entityName,propertyName).ToUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public partial class OracleMethod : DefaultDbMethod, IDbMethods
|
public partial class OracleMethod : DefaultDbMethod, IDbMethods
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user