mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-16 04:59:34 +08:00
OceanBaseForOracle同步Oracle修改
This commit is contained in:
parent
9858f32706
commit
842e69b733
@ -72,14 +72,14 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetLimit()
|
||||
{
|
||||
return "AND ROWNUM=1";
|
||||
}
|
||||
}
|
||||
public partial class OceanBaseForOracleMethod : DefaultDbMethod, IDbMethods
|
||||
{
|
||||
public override string IsNullOrEmpty(MethodCallExpressionModel model)
|
||||
{
|
||||
var parameter = model.Args[0];
|
||||
return string.Format("( {0} IS NULL )", parameter.MemberName);
|
||||
}
|
||||
public override string WeekOfYear(MethodCallExpressionModel mode)
|
||||
{
|
||||
var parameterNameA = mode.Args[0].MemberName;
|
||||
@ -104,7 +104,14 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
}
|
||||
public override string GetStringJoinSelector(string result, string separator)
|
||||
{
|
||||
return $"listagg(to_char({result}),'{separator}') within group(order by {result}) ";
|
||||
if (result.Contains(","))
|
||||
{
|
||||
return $"listagg(to_char({result.Split(',').First()}),'{separator}') within group(order by {result.Split(',').Last()}) ";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"listagg(to_char({result}),'{separator}') within group(order by {result}) ";
|
||||
}
|
||||
}
|
||||
public override string HasValue(MethodCallExpressionModel model)
|
||||
{
|
||||
@ -211,8 +218,10 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
return string.Format("(CAST(TO_CHAR({0},'mi') AS NUMBER))", parameter.MemberName);
|
||||
case DateType.Millisecond:
|
||||
return string.Format("(CAST(TO_CHAR({0},'ff3') AS NUMBER))", parameter.MemberName);
|
||||
case DateType.Quarter:
|
||||
return string.Format("(CAST(TO_CHAR({0},'q') AS NUMBER))", parameter.MemberName);
|
||||
case DateType.Weekday:
|
||||
return $" to_char({parameter.MemberName},'day') ";
|
||||
return $" (TO_NUMBER(TO_CHAR({parameter.MemberName}, 'D'))-1) ";
|
||||
case DateType.Day:
|
||||
default:
|
||||
return string.Format("(CAST(TO_CHAR({0},'dd') AS NUMBER))", parameter.MemberName);
|
||||
@ -275,6 +284,7 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
var parameter = model.Args[0];
|
||||
return string.Format(" TO_TIMESTAMP({0}, 'YYYY-MM-DD HH24:MI:SS.FF') ", parameter.MemberName);
|
||||
}
|
||||
|
||||
public override string ToDateShort(MethodCallExpressionModel model)
|
||||
{
|
||||
var parameter = model.Args[0];
|
||||
@ -311,7 +321,47 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
}
|
||||
public override string DateIsSameByType(MethodCallExpressionModel model)
|
||||
{
|
||||
throw new NotSupportedException("Oracle NotSupportedException DateIsSameDay");
|
||||
var parameter = model.Args[0];
|
||||
var parameter2 = model.Args[1];
|
||||
var parameter3 = model.Args[2];
|
||||
|
||||
var dateType = parameter3.MemberValue.ObjToString().ToLower();
|
||||
var date1 = parameter.MemberName;
|
||||
var date2 = parameter2.MemberName;
|
||||
|
||||
if (dateType == "year")
|
||||
{
|
||||
return string.Format("(EXTRACT(YEAR FROM {0}) = EXTRACT(YEAR FROM {1}))", date1, date2);
|
||||
}
|
||||
else if (dateType == "month")
|
||||
{
|
||||
return string.Format("(EXTRACT(YEAR FROM {0}) = EXTRACT(YEAR FROM {1}) AND EXTRACT(MONTH FROM {0}) = EXTRACT(MONTH FROM {1}))", date1, date2);
|
||||
}
|
||||
else if (dateType == "day")
|
||||
{
|
||||
return string.Format("(TRUNC({0}) = TRUNC({1}))", date1, date2);
|
||||
}
|
||||
else if (dateType == "hour")
|
||||
{
|
||||
return string.Format("(TRUNC({0}, 'HH24') = TRUNC({1}, 'HH24'))", date1, date2);
|
||||
}
|
||||
else if (dateType == "minute")
|
||||
{
|
||||
return string.Format("(TRUNC({0}, 'MI') = TRUNC({1}, 'MI'))", date1, date2);
|
||||
}
|
||||
else if (dateType == "second")
|
||||
{
|
||||
return string.Format("(TRUNC({0}, 'SS') = TRUNC({1}, 'SS'))", date1, date2);
|
||||
}
|
||||
else if (dateType == "week" || dateType == "weekday")
|
||||
{
|
||||
return string.Format("(TRUNC({0}, 'IW') = TRUNC({1}, 'IW'))", date1, date2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 默认按天比较
|
||||
return string.Format("(TRUNC({0}) = TRUNC({1}))", date1, date2);
|
||||
}
|
||||
}
|
||||
public override string Length(MethodCallExpressionModel model)
|
||||
{
|
||||
@ -380,7 +430,28 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
{
|
||||
var parameterNameA = mode.Args[0].MemberName;
|
||||
var parameterNameB = mode.Args[1].MemberName;
|
||||
return $" SUBSTR({parameterNameA}, -2, {parameterNameB}) ";
|
||||
return $" SUBSTR({parameterNameA}, (LENGTH({parameterNameA})-2), {parameterNameB}) ";
|
||||
}
|
||||
|
||||
public override string Ceil(MethodCallExpressionModel mode)
|
||||
{
|
||||
var parameterNameA = mode.Args[0].MemberName;
|
||||
return $" CEIL({parameterNameA}) ";
|
||||
}
|
||||
|
||||
public override string NewUid(MethodCallExpressionModel mode)
|
||||
{
|
||||
return " SUBSTR(LOWER(RAWTOHEX(SYS_GUID())), 1, 8) ||\r\n '-' ||\r\n SUBSTR(LOWER(RAWTOHEX(SYS_GUID())), 9, 4) ||\r\n '-' ||\r\n SUBSTR(LOWER(RAWTOHEX(SYS_GUID())), 13, 4) ||\r\n '-' ||\r\n SUBSTR(LOWER(RAWTOHEX(SYS_GUID())), 17, 4) ||\r\n '-' ||\r\n SUBSTR(LOWER(RAWTOHEX(SYS_GUID())), 21) ";
|
||||
}
|
||||
public override string FullTextContains(MethodCallExpressionModel mode)
|
||||
{
|
||||
var columns = mode.Args[0].MemberName;
|
||||
if (mode.Args[0].MemberValue is List<string>)
|
||||
{
|
||||
columns = "(" + string.Join(",", mode.Args[0].MemberValue as List<string>) + ")";
|
||||
}
|
||||
var searchWord = mode.Args[1].MemberName;
|
||||
return $" CONTAINS({columns}, {searchWord}, 1) ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
{
|
||||
var isFirst = pkList.First() == item;
|
||||
var whereString = isFirst ? " " : " AND ";
|
||||
whereString += GetOracleUpdateColums(item);
|
||||
whereString += GetOracleUpdateColums(item, true);
|
||||
whereList.Add(whereString);
|
||||
}
|
||||
return string.Format("{0} {1} WHERE {2};", updateTable, setValues, string.Join("", whereList));
|
||||
@ -46,9 +46,15 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string GetOracleUpdateColums(DbColumnInfo m)
|
||||
private string GetOracleUpdateColums(DbColumnInfo m, bool isWhere = false)
|
||||
{
|
||||
return string.Format("\"{0}\"={1} ", m.DbColumnName.ToUpper(IsUppper), base.GetDbColumn(m, FormatValue(m.Value, m.IsPrimarykey, m.PropertyName)));
|
||||
|
||||
var result = string.Format("\"{0}\"={1} ", m.DbColumnName.ToUpper(IsUppper), base.GetDbColumn(m, FormatValue(m.Value, m.IsPrimarykey, m.PropertyName)));
|
||||
if (isWhere && m.Value == null)
|
||||
{
|
||||
result = result.Replace("=NULL ", " is NULL ");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
int i = 0;
|
||||
public object FormatValue(object value, bool isPrimaryKey, string name)
|
||||
|
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar.OceanBaseForOracle
|
||||
{
|
||||
internal class QueryableFormat
|
||||
{
|
||||
public Type Type { get; set; }
|
||||
public string TypeString { get; set; }
|
||||
public string Format { get; set; }
|
||||
public string PropertyName { get; set; }
|
||||
public string MethodName { get; set; }
|
||||
public MethodInfo MethodInfo { get; set; }
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
namespace SqlSugar.OceanBaseForOracle
|
||||
{
|
||||
@ -10,17 +11,22 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
public const string Dot = ".";
|
||||
public const char DotChar = '.';
|
||||
internal const string Space = " ";
|
||||
internal const char SpaceChar =' ';
|
||||
internal const string AssemblyName = "SqlSugar";
|
||||
internal const string ReplaceKey = "{662E689B-17A1-4D06-9D27-F29EAB8BC3D6}";
|
||||
internal const char SpaceChar = ' ';
|
||||
internal const string AssemblyName = "SqlSugar.OceanBaseForOracle";
|
||||
internal static string ReplaceKey = "{" + Guid.NewGuid() + "}";
|
||||
internal const string ReplaceCommaKey = "{112A689B-17A1-4A06-9D27-A39EAB8BC3D5}";
|
||||
internal const string GroupReplaceKey = "{GroupReplaceKey_l33asdysaas1231s}";
|
||||
|
||||
internal static Type UShortType = typeof(ushort);
|
||||
internal static Type ULongType = typeof(ulong);
|
||||
internal static Type UIntType = typeof(uint);
|
||||
internal static Type IntType = typeof(int);
|
||||
internal static Type LongType = typeof(long);
|
||||
internal static Type GuidType = typeof(Guid);
|
||||
internal static Type BoolType = typeof(bool);
|
||||
internal static Type BoolTypeNull = typeof(bool?);
|
||||
internal static Type ByteType = typeof(Byte);
|
||||
internal static Type SByteType = typeof(sbyte);
|
||||
internal static Type ObjType = typeof(object);
|
||||
internal static Type DobType = typeof(double);
|
||||
internal static Type FloatType = typeof(float);
|
||||
@ -31,7 +37,7 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
internal static Type DateTimeOffsetType = typeof(DateTimeOffset);
|
||||
internal static Type TimeSpanType = typeof(TimeSpan);
|
||||
internal static Type ByteArrayType = typeof(byte[]);
|
||||
internal static Type ModelType= typeof(ModelContext);
|
||||
internal static Type ModelType = typeof(ModelContext);
|
||||
internal static Type DynamicType = typeof(ExpandoObject);
|
||||
internal static Type Dicii = typeof(KeyValuePair<int, int>);
|
||||
internal static Type DicIS = typeof(KeyValuePair<int, string>);
|
||||
@ -42,6 +48,8 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
internal static Type DicArraySS = typeof(Dictionary<string, string>);
|
||||
internal static Type DicArraySO = typeof(Dictionary<string, object>);
|
||||
|
||||
public static Type SqlConvertType = typeof(SqlSugar.DbConvert.NoParameterCommonPropertyConvert);
|
||||
|
||||
public static Type SugarType = typeof(SqlSugarProvider);
|
||||
|
||||
|
||||
@ -56,7 +64,7 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
typeof(short),
|
||||
typeof(ushort),
|
||||
};
|
||||
|
||||
//internal static CultureInfo EnCultureInfo = new CultureInfo("en");
|
||||
|
||||
internal static string[] DateTypeStringList = new string[]
|
||||
{
|
||||
@ -69,5 +77,8 @@ namespace SqlSugar.OceanBaseForOracle
|
||||
"Millisecond",
|
||||
"Date"
|
||||
};
|
||||
|
||||
public static ConstantExpression ExpTrue = Expression.Constant(true);
|
||||
public static ConstantExpression ExpFalse = Expression.Constant(false);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user