mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update Core
This commit is contained in:
parent
0aa7641735
commit
039e78a31a
@ -216,6 +216,13 @@ namespace SqlSugar
|
|||||||
resolveExpress.MappingColumns = Context.MappingColumns;
|
resolveExpress.MappingColumns = Context.MappingColumns;
|
||||||
resolveExpress.MappingTables = Context.MappingTables;
|
resolveExpress.MappingTables = Context.MappingTables;
|
||||||
resolveExpress.IgnoreComumnList = Context.IgnoreColumns;
|
resolveExpress.IgnoreComumnList = Context.IgnoreColumns;
|
||||||
|
resolveExpress.InitMappingInfo = this.Context.InitMppingInfo;
|
||||||
|
resolveExpress.RefreshMapping = () =>
|
||||||
|
{
|
||||||
|
resolveExpress.MappingColumns = Context.MappingColumns;
|
||||||
|
resolveExpress.MappingTables = Context.MappingTables;
|
||||||
|
resolveExpress.IgnoreComumnList = Context.IgnoreColumns;
|
||||||
|
};
|
||||||
resolveExpress.Resolve(expression, resolveType);
|
resolveExpress.Resolve(expression, resolveType);
|
||||||
this.Parameters.AddRange(resolveExpress.Parameters);
|
this.Parameters.AddRange(resolveExpress.Parameters);
|
||||||
var reval = resolveExpress.Result;
|
var reval = resolveExpress.Result;
|
||||||
|
@ -28,9 +28,9 @@ namespace SqlSugar
|
|||||||
public int ExecuteCommand()
|
public int ExecuteCommand()
|
||||||
{
|
{
|
||||||
PreToSql();
|
PreToSql();
|
||||||
|
Check.Exception(UpdateBuilder.WhereValues.IsNullOrEmpty() && GetPrimaryKeys().IsNullOrEmpty(), "You cannot have no primary key and no conditions");
|
||||||
string sql = UpdateBuilder.ToSqlString();
|
string sql = UpdateBuilder.ToSqlString();
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
Check.Exception(UpdateBuilder.WhereValues.IsNullOrEmpty() && GetPrimaryKeys().IsNullOrEmpty(), "You cannot have no primary key and no conditions");
|
|
||||||
return this.Ado.ExecuteCommand(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray());
|
return this.Ado.ExecuteCommand(sql, UpdateBuilder.Parameters == null ? null : UpdateBuilder.Parameters.ToArray());
|
||||||
}
|
}
|
||||||
public Task<int> ExecuteCommandAsync()
|
public Task<int> ExecuteCommandAsync()
|
||||||
|
@ -99,6 +99,8 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual string SqlTranslationLeft { get { return "["; } }
|
public virtual string SqlTranslationLeft { get { return "["; } }
|
||||||
public virtual string SqlTranslationRight { get { return "]"; } }
|
public virtual string SqlTranslationRight { get { return "]"; } }
|
||||||
|
public virtual Action<Type> InitMappingInfo { get; set; }
|
||||||
|
public virtual Action RefreshMapping { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Core methods
|
#region Core methods
|
||||||
@ -143,7 +145,7 @@ namespace SqlSugar
|
|||||||
else if (isMapping)
|
else if (isMapping)
|
||||||
{
|
{
|
||||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
|
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
|
||||||
return SqlTranslationLeft + (mappingInfo == null ? entityName : mappingInfo.EntityName) + SqlTranslationRight;
|
return SqlTranslationLeft + (mappingInfo == null ? entityName : mappingInfo.DbTableName) + SqlTranslationRight;
|
||||||
}
|
}
|
||||||
else if (isComplex)
|
else if (isComplex)
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,13 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var exp = expression as MethodCallExpression;
|
var exp = expression as MethodCallExpression;
|
||||||
var resType = exp.Method.ReturnType;
|
var resType = exp.Method.ReturnType;
|
||||||
var name = resType.GetGenericArguments().First().Name;
|
var entityType = resType.GetGenericArguments().First();
|
||||||
|
var name = entityType.Name;
|
||||||
|
if (this.Context.InitMappingInfo != null)
|
||||||
|
{
|
||||||
|
this.Context.InitMappingInfo(entityType);
|
||||||
|
this.Context.RefreshMapping();
|
||||||
|
}
|
||||||
return "FROM "+this.Context.GetTranslationTableName(name, true);
|
return "FROM "+this.Context.GetTranslationTableName(name, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ namespace SqlSugar
|
|||||||
ExpressionResult Result { get; set; }
|
ExpressionResult Result { get; set; }
|
||||||
string SqlParameterKeyWord { get; }
|
string SqlParameterKeyWord { get; }
|
||||||
string SingleTableNameSubqueryShortName { get; set; }
|
string SingleTableNameSubqueryShortName { get; set; }
|
||||||
|
Action<Type> InitMappingInfo { get; set; }
|
||||||
|
Action RefreshMapping { get; set; }
|
||||||
|
|
||||||
string GetAsString(string fieldName, string fieldValue);
|
string GetAsString(string fieldName, string fieldValue);
|
||||||
void Resolve(Expression expression, ResolveExpressType resolveType);
|
void Resolve(Expression expression, ResolveExpressType resolveType);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<Version>4.5.2.6</Version>
|
<Version>4.5.2.8</Version>
|
||||||
<Copyright>sun_kai_xuan</Copyright>
|
<Copyright>sun_kai_xuan</Copyright>
|
||||||
<PackageProjectUrl>https://github.com/sunkaixuan/SqlSugar</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/sunkaixuan/SqlSugar</PackageProjectUrl>
|
||||||
<PackageLicenseUrl></PackageLicenseUrl>
|
<PackageLicenseUrl></PackageLicenseUrl>
|
||||||
|
Loading…
Reference in New Issue
Block a user