mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-12-05 03:17:41 +08:00
Synchronization code
This commit is contained in:
@@ -833,6 +833,18 @@ namespace SqlSugar
|
||||
{
|
||||
return new SaveableProvider<T>(this, saveObject);
|
||||
}
|
||||
public StorageableDataTable Storageable(List<Dictionary<string, object>> dictionaryList, string tableName)
|
||||
{
|
||||
DataTable dt = this.Context.Utilities.DictionaryListToDataTable(dictionaryList);
|
||||
dt.TableName = tableName;
|
||||
return this.Context.Storageable(dt);
|
||||
}
|
||||
public StorageableDataTable Storageable(Dictionary<string, object> dictionary, string tableName)
|
||||
{
|
||||
DataTable dt = this.Context.Utilities.DictionaryListToDataTable(new List<Dictionary<string, object>>() { dictionary });
|
||||
dt.TableName = tableName;
|
||||
return this.Context.Storageable(dt);
|
||||
}
|
||||
public IStorageable<T> Storageable<T>(List<T> dataList) where T : class, new()
|
||||
{
|
||||
this.InitMappingInfo<T>();
|
||||
|
||||
@@ -566,6 +566,14 @@ namespace SqlSugar
|
||||
{
|
||||
return ScopedContext.SqlQueryable<T>(sql);
|
||||
}
|
||||
public StorageableDataTable Storageable(List<Dictionary<string, object>> dictionaryList, string tableName)
|
||||
{
|
||||
return ScopedContext.Storageable(dictionaryList, tableName);
|
||||
}
|
||||
public StorageableDataTable Storageable(Dictionary<string, object> dictionary, string tableName)
|
||||
{
|
||||
return ScopedContext.Storageable(dictionary, tableName);
|
||||
}
|
||||
|
||||
public IStorageable<T> Storageable<T>(List<T> dataList) where T : class, new()
|
||||
{
|
||||
|
||||
@@ -681,5 +681,13 @@ namespace SqlSugar
|
||||
model.Args[0].MemberName = name;
|
||||
return AggregateSum(model);
|
||||
}
|
||||
public virtual string JsonListObjectAny(MethodCallExpressionModel model)
|
||||
{
|
||||
throw new NotImplementedException("Current database no support");
|
||||
}
|
||||
public virtual string JsonArrayAny(MethodCallExpressionModel model)
|
||||
{
|
||||
throw new NotImplementedException("Current database no support");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,5 +100,7 @@ namespace SqlSugar
|
||||
string JsonLike(MethodCallExpressionModel model);
|
||||
string Collate(MethodCallExpressionModel model);
|
||||
string AggregateSumNoNull(MethodCallExpressionModel model);
|
||||
string JsonListObjectAny(MethodCallExpressionModel model);
|
||||
string JsonArrayAny(MethodCallExpressionModel model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,5 +256,15 @@ namespace SqlSugar
|
||||
public static DateTime Oracle_ToDate(string date,string format) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
public static string Oracle_ToChar(DateTime date, string format) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
public static int SqlServer_DateDiff(string dateType,DateTime date1,DateTime date2) { throw new NotSupportedException("Can only be used in expressions"); }
|
||||
|
||||
public static bool JsonListObjectAny(object jsonListObject, string fieldName, object value)
|
||||
{
|
||||
throw new NotSupportedException("Can only be used in expressions");
|
||||
}
|
||||
|
||||
public static bool JsonArrayAny(object jsonArray,object arrayValue)
|
||||
{
|
||||
throw new NotSupportedException("Can only be used in expressions");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -752,6 +752,10 @@ namespace SqlSugar
|
||||
return this.Context.DbMehtods.Collate(model);
|
||||
case "AggregateSumNoNull":
|
||||
return this.Context.DbMehtods.AggregateSumNoNull(model);
|
||||
case "JsonListObjectAny":
|
||||
return this.Context.DbMehtods.JsonListObjectAny(model);
|
||||
case "JsonArrayAny":
|
||||
return this.Context.DbMehtods.JsonArrayAny(model);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -137,6 +137,8 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Saveable
|
||||
StorageableDataTable Storageable(List<Dictionary<string, object>> dictionaryList, string tableName);
|
||||
StorageableDataTable Storageable(Dictionary<string, object> dictionary, string tableName);
|
||||
IStorageable<T> Storageable<T>(List<T> dataList) where T : class, new();
|
||||
IStorageable<T> Storageable<T>(T data) where T : class, new();
|
||||
StorageableDataTable Storageable(DataTable data);
|
||||
|
||||
@@ -217,5 +217,28 @@ namespace SqlSugar
|
||||
{
|
||||
return $"{memberName1}->\"$.{memberName2}\"";
|
||||
}
|
||||
|
||||
public override string JsonArrayAny(MethodCallExpressionModel model)
|
||||
{
|
||||
if (UtilMethods.IsNumber(model.Args[1].MemberValue.GetType().Name))
|
||||
{
|
||||
return $"JSON_CONTAINS({model.Args[0].MemberName}, '{model.Args[1].MemberValue}')";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"JSON_CONTAINS({model.Args[0].MemberName}, '\"{model.Args[1].MemberValue.ObjToStringNoTrim().ToSqlFilter()}\"')";
|
||||
}
|
||||
}
|
||||
public override string JsonListObjectAny(MethodCallExpressionModel model)
|
||||
{
|
||||
if (UtilMethods.IsNumber(model.Args[2].MemberValue.GetType().Name))
|
||||
{
|
||||
return $"JSON_CONTAINS({model.Args[0].MemberName},'{{\"{model.Args[1].MemberValue}\":{model.Args[2].MemberValue}}}')";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"JSON_CONTAINS({model.Args[0].MemberName},'{{\"{model.Args[1].MemberValue}\":\"{model.Args[2].MemberValue.ObjToStringNoTrim().ToSqlFilter()}\"}}')";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,5 +443,28 @@ namespace SqlSugar
|
||||
//var parameter1 = model.Args[1];
|
||||
return $" ({parameter.MemberName}::json) ";
|
||||
}
|
||||
|
||||
public override string JsonArrayAny(MethodCallExpressionModel model)
|
||||
{
|
||||
if (UtilMethods.IsNumber(model.Args[1].MemberValue.GetType().Name))
|
||||
{
|
||||
return $"{model.Args[0].MemberName}::jsonb @> '[{model.Args[1].MemberValue.ObjToStringNoTrim().ToSqlFilter()}]'::jsonb";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{model.Args[0].MemberName}::jsonb @> '[\"{model.Args[1].MemberValue}\"]'::jsonb";
|
||||
}
|
||||
}
|
||||
public override string JsonListObjectAny(MethodCallExpressionModel model)
|
||||
{
|
||||
if (UtilMethods.IsNumber(model.Args[2].MemberValue.GetType().Name))
|
||||
{
|
||||
return $"{model.Args[0].MemberName}::jsonb @> '[{{\"{model.Args[1].MemberValue}\":{model.Args[2].MemberValue}}}]'::jsonb";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{model.Args[0].MemberName}::jsonb @> '[{{\"{model.Args[1].MemberValue}\":\"{model.Args[2].MemberValue.ObjToStringNoTrim().ToSqlFilter()}\"}}]'::jsonb";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,7 +569,14 @@ namespace SqlSugar
|
||||
{
|
||||
return ScopedContext.SqlQueryable<T>(sql);
|
||||
}
|
||||
|
||||
public StorageableDataTable Storageable(List<Dictionary<string, object>> dictionaryList, string tableName)
|
||||
{
|
||||
return ScopedContext.Storageable(dictionaryList, tableName);
|
||||
}
|
||||
public StorageableDataTable Storageable(Dictionary<string, object> dictionary, string tableName)
|
||||
{
|
||||
return ScopedContext.Storageable(dictionary, tableName);
|
||||
}
|
||||
public IStorageable<T> Storageable<T>(List<T> dataList) where T : class, new()
|
||||
{
|
||||
return ScopedContext.Storageable(dataList);
|
||||
|
||||
Reference in New Issue
Block a user