mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-16 16:50:41 +08:00
Synchronization code
This commit is contained in:
parent
644adf43e2
commit
2dbc2ec207
@ -38,7 +38,20 @@ namespace SqlSugar
|
|||||||
Context = result
|
Context = result
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
public CommonMethodInfo EnableDiffLogEvent(object businessData = null)
|
||||||
|
{
|
||||||
|
if (Context == null)
|
||||||
|
{
|
||||||
|
return new CommonMethodInfo();
|
||||||
|
}
|
||||||
|
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
||||||
|
var newMethod = inertable.GetType().GetMyMethod("EnableDiffLogEvent", 1, typeof(object));
|
||||||
|
var result = newMethod.Invoke(inertable, new object[] { businessData });
|
||||||
|
return new CommonMethodInfo()
|
||||||
|
{
|
||||||
|
Context = result
|
||||||
|
};
|
||||||
|
}
|
||||||
public CommonMethodInfo SplitTable()
|
public CommonMethodInfo SplitTable()
|
||||||
{
|
{
|
||||||
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
||||||
|
@ -82,6 +82,8 @@ namespace SqlSugar
|
|||||||
attributeType.GetProperty(nameof(SugarColumn.ExtendedAttribute)),
|
attributeType.GetProperty(nameof(SugarColumn.ExtendedAttribute)),
|
||||||
attributeType.GetProperty(nameof(SugarColumn.IsDisabledAlterColumn)),
|
attributeType.GetProperty(nameof(SugarColumn.IsDisabledAlterColumn)),
|
||||||
attributeType.GetProperty(nameof(SugarColumn.IsOwnsOne)),
|
attributeType.GetProperty(nameof(SugarColumn.IsOwnsOne)),
|
||||||
|
attributeType.GetProperty(nameof(SugarColumn.InsertServerTime)),
|
||||||
|
attributeType.GetProperty(nameof(SugarColumn.UpdateServerTime)),
|
||||||
attributeType.GetProperty(nameof(SugarColumn.QuerySql))
|
attributeType.GetProperty(nameof(SugarColumn.QuerySql))
|
||||||
}
|
}
|
||||||
, new object[] {
|
, new object[] {
|
||||||
@ -108,6 +110,8 @@ namespace SqlSugar
|
|||||||
sugarTable.ExtendedAttribute,
|
sugarTable.ExtendedAttribute,
|
||||||
sugarTable.IsDisabledAlterColumn,
|
sugarTable.IsDisabledAlterColumn,
|
||||||
sugarTable.IsOwnsOne,
|
sugarTable.IsOwnsOne,
|
||||||
|
sugarTable.InsertServerTime,
|
||||||
|
sugarTable.UpdateServerTime,
|
||||||
sugarTable.QuerySql
|
sugarTable.QuerySql
|
||||||
});
|
});
|
||||||
return attributeBuilder;
|
return attributeBuilder;
|
||||||
|
@ -60,6 +60,16 @@ namespace SqlSugar
|
|||||||
Context = result
|
Context = result
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
public CommonMethodInfo EnableDiffLogEvent(object businessData = null)
|
||||||
|
{
|
||||||
|
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
||||||
|
var newMethod = inertable.GetType().GetMyMethod("EnableDiffLogEvent", 1, typeof(object));
|
||||||
|
var result = newMethod.Invoke(inertable, new object[] { businessData });
|
||||||
|
return new CommonMethodInfo()
|
||||||
|
{
|
||||||
|
Context = result
|
||||||
|
};
|
||||||
|
}
|
||||||
public CommonMethodInfo IgnoreColumns(params string [] ignoreColumns)
|
public CommonMethodInfo IgnoreColumns(params string [] ignoreColumns)
|
||||||
{
|
{
|
||||||
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
||||||
|
@ -317,7 +317,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
column.DbColumnName = column.PropertyName;
|
column.DbColumnName = column.PropertyName;
|
||||||
}
|
}
|
||||||
if (isMapping)
|
if (isMapping&&column.ForOwnsOnePropertyInfo==null)
|
||||||
{
|
{
|
||||||
columnInfo.DbColumnName = GetDbColumnName(column.PropertyName);
|
columnInfo.DbColumnName = GetDbColumnName(column.PropertyName);
|
||||||
}
|
}
|
||||||
|
@ -1500,7 +1500,21 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return this.Select<TResult>(this.SqlBuilder.SqlSelectAll);
|
if (this.QueryBuilder.IsSingle()&&this.EntityInfo?.Type?.GetCustomAttribute<SplitTableAttribute>() != null&& this.QueryBuilder?.SelectValue?.ToString()=="*")
|
||||||
|
{
|
||||||
|
var columnAarray = this.Context.EntityMaintenance.GetEntityInfo<T>().Columns;
|
||||||
|
var sql = string.Empty;
|
||||||
|
var columns= columnAarray.Where(it => typeof(TResult).GetProperties().Any(s => s.Name.EqualCase(it.PropertyName))).Where(it => it.IsIgnore == false).ToList();
|
||||||
|
if (columns.Any())
|
||||||
|
{
|
||||||
|
sql = string.Join(",", columns.Select(it => $"{SqlBuilder.GetTranslationColumnName(it.DbColumnName)} AS {SqlBuilder.GetTranslationColumnName(it.PropertyName)} "));
|
||||||
|
}
|
||||||
|
return this.Select<TResult>(sql);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.Select<TResult>(this.SqlBuilder.SqlSelectAll);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1687,6 +1701,7 @@ namespace SqlSugar
|
|||||||
//}
|
//}
|
||||||
var unionall = this.Context._UnionAll(tableQueryables.ToArray());
|
var unionall = this.Context._UnionAll(tableQueryables.ToArray());
|
||||||
unionall.QueryBuilder.Includes = this.QueryBuilder.Includes;
|
unionall.QueryBuilder.Includes = this.QueryBuilder.Includes;
|
||||||
|
unionall.QueryBuilder.EntityType = typeof(T);
|
||||||
if (unionall.QueryBuilder.Includes?.Any()==true)
|
if (unionall.QueryBuilder.Includes?.Any()==true)
|
||||||
{
|
{
|
||||||
unionall.QueryBuilder.NoCheckInclude = true;
|
unionall.QueryBuilder.NoCheckInclude = true;
|
||||||
|
@ -653,8 +653,12 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return resulut.Select<T>("unionTable.*");
|
return resulut.Select<T>("unionTable.*");
|
||||||
}
|
}
|
||||||
else
|
else if (this.Context.CurrentConnectionConfig?.MoreSettings?.IsWithNoLockQuery==true)
|
||||||
{
|
{
|
||||||
|
return resulut.Select<T>(sqlBuilder.SqlSelectAll).With(SqlWith.Null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return resulut.Select<T>(sqlBuilder.SqlSelectAll);
|
return resulut.Select<T>(sqlBuilder.SqlSelectAll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@ namespace SqlSugar
|
|||||||
internal MethodInfo MethodInfo { get; set; }
|
internal MethodInfo MethodInfo { get; set; }
|
||||||
internal object objectValue { get; set; }
|
internal object objectValue { get; set; }
|
||||||
|
|
||||||
public int ExecuteCommandWithOptLock(bool isThrowError = false)
|
public int ExecuteCommandWithOptLock(bool isThrowError = false)
|
||||||
{
|
{
|
||||||
if (Context == null) return 0;
|
if (Context == null) return 0;
|
||||||
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
||||||
var result = inertable.GetType().GetMyMethod("ExecuteCommandWithOptLock",1,typeof(bool)).Invoke(inertable, new object[] { isThrowError });
|
var result = inertable.GetType().GetMyMethod("ExecuteCommandWithOptLock", 1, typeof(bool)).Invoke(inertable, new object[] { isThrowError });
|
||||||
return (int)result;
|
return (int)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,13 +26,13 @@ namespace SqlSugar
|
|||||||
if (Context == null) return 0;
|
if (Context == null) return 0;
|
||||||
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
||||||
var result = inertable.GetType().GetMyMethod("ExecuteCommandWithOptLockAsync", 1, typeof(bool)).Invoke(inertable, new object[] { isThrowError });
|
var result = inertable.GetType().GetMyMethod("ExecuteCommandWithOptLockAsync", 1, typeof(bool)).Invoke(inertable, new object[] { isThrowError });
|
||||||
return await(Task<int>)result;
|
return await (Task<int>)result;
|
||||||
}
|
}
|
||||||
public int ExecuteCommand()
|
public int ExecuteCommand()
|
||||||
{
|
{
|
||||||
if (Context == null) return 0;
|
if (Context == null) return 0;
|
||||||
var inertable=MethodInfo.Invoke(Context, new object[] { objectValue });
|
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
||||||
var result= inertable.GetType().GetMethod("ExecuteCommand").Invoke(inertable,new object[] { });
|
var result = inertable.GetType().GetMethod("ExecuteCommand").Invoke(inertable, new object[] { });
|
||||||
return (int)result;
|
return (int)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,9 +40,23 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (Context == null) return 0;
|
if (Context == null) return 0;
|
||||||
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
||||||
var result = inertable.GetType().GetMyMethod("ExecuteCommandAsync",0).Invoke(inertable, new object[] { });
|
var result = inertable.GetType().GetMyMethod("ExecuteCommandAsync", 0).Invoke(inertable, new object[] { });
|
||||||
return await (Task<int>)result;
|
return await (Task<int>)result;
|
||||||
}
|
}
|
||||||
|
public UpdateCommonMethodInfo EnableDiffLogEvent(object businessData = null)
|
||||||
|
{
|
||||||
|
if(Context == null)
|
||||||
|
{
|
||||||
|
return new UpdateCommonMethodInfo();
|
||||||
|
}
|
||||||
|
var inertable = MethodInfo.Invoke(Context, new object[] { objectValue });
|
||||||
|
var newMethod = inertable.GetType().GetMyMethod("EnableDiffLogEvent", 1, typeof(object));
|
||||||
|
var result = newMethod.Invoke(inertable, new object[] { businessData });
|
||||||
|
return new UpdateCommonMethodInfo()
|
||||||
|
{
|
||||||
|
Context = result
|
||||||
|
};
|
||||||
|
}
|
||||||
public UpdateCommonMethodInfo IgnoreColumns(params string[] ignoreColumns)
|
public UpdateCommonMethodInfo IgnoreColumns(params string[] ignoreColumns)
|
||||||
{
|
{
|
||||||
if (Context == null)
|
if (Context == null)
|
||||||
|
@ -386,6 +386,10 @@ namespace SqlSugar
|
|||||||
UpdateServerTime = column.UpdateServerTime,
|
UpdateServerTime = column.UpdateServerTime,
|
||||||
IsPrimarykey=column.IsPrimarykey
|
IsPrimarykey=column.IsPrimarykey
|
||||||
};
|
};
|
||||||
|
if (column.ForOwnsOnePropertyInfo != null)
|
||||||
|
{
|
||||||
|
columnInfo.DbColumnName = column.DbColumnName;
|
||||||
|
}
|
||||||
if (columnInfo.PropertyType.IsEnum() && columnInfo.Value != null)
|
if (columnInfo.PropertyType.IsEnum() && columnInfo.Value != null)
|
||||||
{
|
{
|
||||||
if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
|
if (this.Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
|
||||||
|
@ -134,6 +134,10 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
var value = GetNewExpressionValue(express.Object);
|
var value = GetNewExpressionValue(express.Object);
|
||||||
var dateString2 = this.Context.DbMehtods.GetDateString(value, format);
|
var dateString2 = this.Context.DbMehtods.GetDateString(value, format);
|
||||||
|
if (IsSqlServerModel())
|
||||||
|
{
|
||||||
|
dateString2= string.Format("FORMAT({0},'{1}','en-US')", value, format);
|
||||||
|
}
|
||||||
if (dateString2 == null)
|
if (dateString2 == null)
|
||||||
{
|
{
|
||||||
var dateString = GeDateFormat(format, value);
|
var dateString = GeDateFormat(format, value);
|
||||||
|
@ -20,6 +20,10 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else if (IsOracle() || IsPg())
|
else if (IsOracle() || IsPg())
|
||||||
{
|
{
|
||||||
|
if (this.Context?.SugarContext?.Context?.CurrentConnectionConfig?.MoreSettings?.DatabaseModel == DbType.SqlServer)
|
||||||
|
{
|
||||||
|
return string.Format("FORMAT({0},'{1}','en-US')", value, formatString);
|
||||||
|
}
|
||||||
if (!(formatString?.Contains("24") == true))
|
if (!(formatString?.Contains("24") == true))
|
||||||
{
|
{
|
||||||
formatString = formatString.Replace("HH", "hh24");
|
formatString = formatString.Replace("HH", "hh24");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -786,6 +786,10 @@ namespace SqlSugar
|
|||||||
if (model.Args.Count > 1)
|
if (model.Args.Count > 1)
|
||||||
{
|
{
|
||||||
var dateString2 = this.Context.DbMehtods.GetDateString(model.Args.First().MemberName.ObjToString(), model.Args.Last().MemberValue.ObjToString());
|
var dateString2 = this.Context.DbMehtods.GetDateString(model.Args.First().MemberName.ObjToString(), model.Args.Last().MemberValue.ObjToString());
|
||||||
|
if (IsSqlServerModel())
|
||||||
|
{
|
||||||
|
return string.Format("FORMAT({0},'{1}','en-US')", model.Args.First().MemberName.ObjToString(), model.Args.Last().MemberValue.ObjToString());
|
||||||
|
}
|
||||||
if (dateString2 != null) return dateString2;
|
if (dateString2 != null) return dateString2;
|
||||||
return GeDateFormat(model.Args.Last().MemberValue.ObjToString(), model.Args.First().MemberName.ObjToString());
|
return GeDateFormat(model.Args.Last().MemberValue.ObjToString(), model.Args.First().MemberName.ObjToString());
|
||||||
}
|
}
|
||||||
@ -999,6 +1003,11 @@ namespace SqlSugar
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsSqlServerModel()
|
||||||
|
{
|
||||||
|
return this.Context?.SugarContext?.Context?.CurrentConnectionConfig?.MoreSettings?.DatabaseModel == DbType.SqlServer;
|
||||||
|
}
|
||||||
|
|
||||||
private string GetLike(string result, bool iLike)
|
private string GetLike(string result, bool iLike)
|
||||||
{
|
{
|
||||||
if (iLike)
|
if (iLike)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -171,7 +172,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
day = group3;
|
day = group3;
|
||||||
}
|
}
|
||||||
return Convert.ToDateTime($"{year}-{month}-{day}");
|
return Convert.ToDateTime($"{year}-{month}-{day}",CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string PadLeft2(string str)
|
private string PadLeft2(string str)
|
||||||
|
Loading…
Reference in New Issue
Block a user