mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-21 02:57:33 +08:00
Synchronization code
This commit is contained in:
@@ -34,7 +34,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
|
|
||||||
var aids = _ParentList.Select(it => parentPkColumn.PropertyInfo.GetValue(it)).ToList();
|
var aids = _ParentList.Select(it => parentPkColumn.PropertyInfo.GetValue(it)).ToList();
|
||||||
var bids = _Context.Queryable<object>().AS(mappingEntity.DbTableName).In(mappingA.DbColumnName, aids)
|
var bids = _Context.Queryable<object>().Filter(mappingEntity.Type).AS(mappingEntity.DbTableName).In(mappingA.DbColumnName, aids)
|
||||||
.Select(mappingB.DbColumnName).ToDataTable()
|
.Select(mappingB.DbColumnName).ToDataTable()
|
||||||
.Rows.Cast<System.Data.DataRow>().Select(it => it[0]).ToList();
|
.Rows.Cast<System.Data.DataRow>().Select(it => it[0]).ToList();
|
||||||
|
|
||||||
|
@@ -26,6 +26,12 @@ namespace SqlSugar
|
|||||||
.Where(it => it.PropertyName != mappingA.PropertyName)
|
.Where(it => it.PropertyName != mappingA.PropertyName)
|
||||||
.Where(it => it.PropertyName != mappingB.PropertyName)
|
.Where(it => it.PropertyName != mappingB.PropertyName)
|
||||||
.Where(it => it.IsPrimarykey && !it.IsIdentity && it.OracleSequenceName.IsNullOrEmpty()).FirstOrDefault();
|
.Where(it => it.IsPrimarykey && !it.IsIdentity && it.OracleSequenceName.IsNullOrEmpty()).FirstOrDefault();
|
||||||
|
var mappingBizDeleteColumn = mappingEntity.Columns.FirstOrDefault(it =>
|
||||||
|
it.DbColumnName.EqualCase("isdelete") ||
|
||||||
|
it.PropertyName.EqualCase("isdelete") ||
|
||||||
|
it.DbColumnName.EqualCase("isdeleted") ||
|
||||||
|
it.PropertyName.EqualCase("isdeleted")
|
||||||
|
);
|
||||||
Check.Exception(mappingA == null || mappingB == null, $"Navigate property {name} error ", $"导航属性{name}配置错误");
|
Check.Exception(mappingA == null || mappingB == null, $"Navigate property {name} error ", $"导航属性{name}配置错误");
|
||||||
List<Dictionary<string, object>> mappgingTables = new List<Dictionary<string, object>>();
|
List<Dictionary<string, object>> mappgingTables = new List<Dictionary<string, object>>();
|
||||||
foreach (var item in parentList)
|
foreach (var item in parentList)
|
||||||
@@ -40,6 +46,10 @@ namespace SqlSugar
|
|||||||
Dictionary<string,object> keyValuePairs = new Dictionary<string,object>();
|
Dictionary<string,object> keyValuePairs = new Dictionary<string,object>();
|
||||||
keyValuePairs.Add(mappingA.DbColumnName, parentId);
|
keyValuePairs.Add(mappingA.DbColumnName, parentId);
|
||||||
keyValuePairs.Add(mappingB.DbColumnName, chidId);
|
keyValuePairs.Add(mappingB.DbColumnName, chidId);
|
||||||
|
if (mappingBizDeleteColumn != null)
|
||||||
|
{
|
||||||
|
keyValuePairs.Add(mappingBizDeleteColumn.DbColumnName, UtilMethods.GetDefaultValue(mappingBizDeleteColumn.UnderType));
|
||||||
|
}
|
||||||
if (mappingPk != null)
|
if (mappingPk != null)
|
||||||
{
|
{
|
||||||
SetMappingTableDefaultValue(mappingPk, keyValuePairs);
|
SetMappingTableDefaultValue(mappingPk, keyValuePairs);
|
||||||
|
@@ -26,6 +26,11 @@ namespace SqlSugar
|
|||||||
.Where(it => it.PropertyName != mappingA.PropertyName)
|
.Where(it => it.PropertyName != mappingA.PropertyName)
|
||||||
.Where(it => it.PropertyName != mappingB.PropertyName)
|
.Where(it => it.PropertyName != mappingB.PropertyName)
|
||||||
.Where(it => it.IsPrimarykey && !it.IsIdentity && it.OracleSequenceName.IsNullOrEmpty()).FirstOrDefault();
|
.Where(it => it.IsPrimarykey && !it.IsIdentity && it.OracleSequenceName.IsNullOrEmpty()).FirstOrDefault();
|
||||||
|
var mappingBizDeleteColumn = mappingEntity.Columns.FirstOrDefault(it =>
|
||||||
|
it.DbColumnName.EqualCase("isdelete") ||
|
||||||
|
it.PropertyName.EqualCase("isdelete") ||
|
||||||
|
it.DbColumnName.EqualCase("isdeleted") ||
|
||||||
|
it.PropertyName.EqualCase("isdeleted"));
|
||||||
Check.Exception(mappingA == null || mappingB == null, $"Navigate property {name} error ", $"导航属性{name}配置错误");
|
Check.Exception(mappingA == null || mappingB == null, $"Navigate property {name} error ", $"导航属性{name}配置错误");
|
||||||
List<Dictionary<string, object>> mappgingTables = new List<Dictionary<string, object>>();
|
List<Dictionary<string, object>> mappgingTables = new List<Dictionary<string, object>>();
|
||||||
var ids=new List<object>();
|
var ids=new List<object>();
|
||||||
@@ -52,6 +57,10 @@ namespace SqlSugar
|
|||||||
Dictionary<string, object> keyValuePairs = new Dictionary<string, object>();
|
Dictionary<string, object> keyValuePairs = new Dictionary<string, object>();
|
||||||
keyValuePairs.Add(mappingA.DbColumnName, parentId);
|
keyValuePairs.Add(mappingA.DbColumnName, parentId);
|
||||||
keyValuePairs.Add(mappingB.DbColumnName, chidId);
|
keyValuePairs.Add(mappingB.DbColumnName, chidId);
|
||||||
|
if (mappingBizDeleteColumn != null)
|
||||||
|
{
|
||||||
|
keyValuePairs.Add(mappingBizDeleteColumn.DbColumnName, UtilMethods.GetDefaultValue(mappingBizDeleteColumn.UnderType));
|
||||||
|
}
|
||||||
if (mappingPk != null)
|
if (mappingPk != null)
|
||||||
{
|
{
|
||||||
SetMappingTableDefaultValue(mappingPk, keyValuePairs);
|
SetMappingTableDefaultValue(mappingPk, keyValuePairs);
|
||||||
|
@@ -249,8 +249,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else if (type == UtilConstants.DateTimeOffsetType)
|
else if (type == UtilConstants.DateTimeOffsetType)
|
||||||
{
|
{
|
||||||
var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);
|
return FormatDateTimeOffset(value);
|
||||||
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
|
||||||
}
|
}
|
||||||
else if (type == UtilConstants.FloatType)
|
else if (type == UtilConstants.FloatType)
|
||||||
{
|
{
|
||||||
@@ -262,6 +261,12 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual string FormatDateTimeOffset(object value)
|
||||||
|
{
|
||||||
|
var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);
|
||||||
|
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -353,8 +353,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else if (type == UtilConstants.DateTimeOffsetType)
|
else if (type == UtilConstants.DateTimeOffsetType)
|
||||||
{
|
{
|
||||||
var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);
|
return FormatDateTimeOffset(value);
|
||||||
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
|
||||||
}
|
}
|
||||||
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
|
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
|
||||||
{
|
{
|
||||||
@@ -381,5 +380,11 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual string FormatDateTimeOffset(object value)
|
||||||
|
{
|
||||||
|
var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);
|
||||||
|
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -71,5 +71,9 @@ namespace SqlSugar
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public override string FormatDateTimeOffset(object value)
|
||||||
|
{
|
||||||
|
return "'" + ((DateTimeOffset)value).ToString("o") + "'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -90,5 +90,9 @@ namespace SqlSugar
|
|||||||
return FormatValue(it.Value);
|
return FormatValue(it.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public override string FormatDateTimeOffset(object value)
|
||||||
|
{
|
||||||
|
return "'"+((DateTimeOffset)value).ToString("o")+"'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user