mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Update Core
This commit is contained in:
parent
9418d30c3e
commit
04256d9d2e
@ -275,6 +275,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
sqlCommand.Dispose();
|
||||
return count;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -310,6 +311,7 @@ namespace SqlSugar
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
SetConnectionEnd(sql);
|
||||
sqlCommand.Dispose();
|
||||
return sqlDataReader;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -339,6 +341,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
sqlCommand.Dispose();
|
||||
return ds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -371,6 +374,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
sqlCommand.Dispose();
|
||||
return scalar;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -404,6 +408,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
sqlCommand.Dispose();
|
||||
return count;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -440,6 +445,7 @@ namespace SqlSugar
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
SetConnectionEnd(sql);
|
||||
sqlCommand.Dispose();
|
||||
return sqlDataReader;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -468,6 +474,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
sqlCommand.Dispose();
|
||||
return scalar;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -71,7 +71,7 @@ namespace SqlSugar
|
||||
}
|
||||
public ISugarQueryable<T> Clone()
|
||||
{
|
||||
var queryable = this.Context.Queryable<T>().WithCacheIF(IsCache, CacheTime);
|
||||
var queryable = this.Context.Queryable<object>().Select<T>().WithCacheIF(IsCache, CacheTime);
|
||||
CopyQueryBuilder(queryable.QueryBuilder);
|
||||
((QueryableProvider<T>)queryable).MapperAction = this.MapperAction;
|
||||
((QueryableProvider<T>)queryable).MapperActionWithCache = this.MapperActionWithCache;
|
||||
|
@ -145,6 +145,14 @@ namespace SqlSugar
|
||||
{
|
||||
ILambdaExpressions resolveExpress = this.LambdaExpressions;
|
||||
this.LambdaExpressions.Clear();
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings != null)
|
||||
{
|
||||
resolveExpress.PgSqlIsAutoToLower = this.Context.CurrentConnectionConfig.MoreSettings.PgSqlIsAutoToLower;
|
||||
}
|
||||
else
|
||||
{
|
||||
resolveExpress.PgSqlIsAutoToLower = true;
|
||||
}
|
||||
resolveExpress.MappingColumns = Context.MappingColumns;
|
||||
resolveExpress.MappingTables = Context.MappingTables;
|
||||
resolveExpress.IgnoreComumnList = Context.IgnoreColumns;
|
||||
|
@ -99,6 +99,14 @@ namespace SqlSugar
|
||||
{
|
||||
ILambdaExpressions resolveExpress = this.LambdaExpressions;
|
||||
this.LambdaExpressions.Clear();
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings != null)
|
||||
{
|
||||
resolveExpress.PgSqlIsAutoToLower = this.Context.CurrentConnectionConfig.MoreSettings.PgSqlIsAutoToLower;
|
||||
}
|
||||
else
|
||||
{
|
||||
resolveExpress.PgSqlIsAutoToLower = true;
|
||||
}
|
||||
resolveExpress.MappingColumns = Context.MappingColumns;
|
||||
resolveExpress.MappingTables = Context.MappingTables;
|
||||
resolveExpress.IgnoreComumnList = Context.IgnoreColumns;
|
||||
|
@ -220,6 +220,14 @@ namespace SqlSugar
|
||||
resolveType = resolveType.IsIn(ResolveExpressType.SelectSingle, ResolveExpressType.FieldSingle) ? ResolveExpressType.WhereSingle : ResolveExpressType.WhereMultiple;
|
||||
}
|
||||
this.LambdaExpressions.Clear();
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings != null)
|
||||
{
|
||||
resolveExpress.PgSqlIsAutoToLower = this.Context.CurrentConnectionConfig.MoreSettings.PgSqlIsAutoToLower;
|
||||
}
|
||||
else
|
||||
{
|
||||
resolveExpress.PgSqlIsAutoToLower = true;
|
||||
}
|
||||
resolveExpress.JoinQueryInfos = Builder.QueryBuilder.JoinQueryInfos;
|
||||
resolveExpress.IsSingle = IsSingle();
|
||||
resolveExpress.MappingColumns = Context.MappingColumns;
|
||||
|
@ -116,6 +116,14 @@ namespace SqlSugar
|
||||
{
|
||||
ILambdaExpressions resolveExpress = this.LambdaExpressions;
|
||||
this.LambdaExpressions.Clear();
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings != null)
|
||||
{
|
||||
resolveExpress.PgSqlIsAutoToLower = this.Context.CurrentConnectionConfig.MoreSettings.PgSqlIsAutoToLower;
|
||||
}
|
||||
else
|
||||
{
|
||||
resolveExpress.PgSqlIsAutoToLower = true;
|
||||
}
|
||||
if (isMapping)
|
||||
{
|
||||
resolveExpress.MappingColumns = Context.MappingColumns;
|
||||
|
@ -352,6 +352,14 @@ namespace SqlSugar
|
||||
ILambdaExpressions expressionContext = sqlBuilder.QueryBuilder.LambdaExpressions;
|
||||
expressionContext.MappingColumns = this.MappingColumns;
|
||||
expressionContext.MappingTables = this.MappingTables;
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings != null)
|
||||
{
|
||||
expressionContext.PgSqlIsAutoToLower = this.Context.CurrentConnectionConfig.MoreSettings.PgSqlIsAutoToLower;
|
||||
}
|
||||
else
|
||||
{
|
||||
expressionContext.PgSqlIsAutoToLower = true;
|
||||
}
|
||||
if (this.Context.CurrentConnectionConfig.ConfigureExternalServices != null)
|
||||
expressionContext.SqlFuncServices = this.Context.CurrentConnectionConfig.ConfigureExternalServices.SqlFuncServices;
|
||||
expressionContext.Resolve(joinExpression, ResolveExpressType.Join);
|
||||
|
@ -13,6 +13,7 @@ namespace SqlSugar
|
||||
/// Some MYSQL databases do not support NVarchar set true
|
||||
/// </summary>
|
||||
public bool MySqlDisableNarvchar { get; set; }
|
||||
public bool PgSqlIsAutoToLower = true;
|
||||
public int DefaultCacheDurationInSeconds { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ namespace SqlSugar
|
||||
public MappingColumnList MappingColumns { get; set; }
|
||||
public MappingTableList MappingTables { get; set; }
|
||||
public IgnoreColumnList IgnoreComumnList { get; set; }
|
||||
public bool PgSqlIsAutoToLower { get; set; }
|
||||
public List<SqlFuncExternal> SqlFuncServices { get; set; }
|
||||
public bool IsSingle
|
||||
{
|
||||
@ -125,6 +126,7 @@ namespace SqlSugar
|
||||
copyContext.InitMappingInfo = this.InitMappingInfo;
|
||||
copyContext.RefreshMapping = this.RefreshMapping;
|
||||
copyContext.ParameterIndex = this.ParameterIndex;
|
||||
copyContext.PgSqlIsAutoToLower = this.PgSqlIsAutoToLower;
|
||||
return copyContext;
|
||||
}
|
||||
public ExpressionContext GetCopyContextWithMapping()
|
||||
@ -138,6 +140,7 @@ namespace SqlSugar
|
||||
copyContext.SqlFuncServices = this.SqlFuncServices;
|
||||
copyContext.InitMappingInfo = this.InitMappingInfo;
|
||||
copyContext.RefreshMapping = this.RefreshMapping;
|
||||
copyContext.PgSqlIsAutoToLower = this.PgSqlIsAutoToLower;
|
||||
return copyContext;
|
||||
}
|
||||
#endregion
|
||||
|
@ -26,6 +26,7 @@ namespace SqlSugar
|
||||
string SingleTableNameSubqueryShortName { get; set; }
|
||||
Action<Type> InitMappingInfo { get; set; }
|
||||
Action RefreshMapping { get; set; }
|
||||
bool PgSqlIsAutoToLower { get; set; }
|
||||
|
||||
string GetAsString(string fieldName, string fieldValue);
|
||||
void Resolve(Expression expression, ResolveExpressType resolveType);
|
||||
|
@ -79,6 +79,7 @@ namespace SqlSugar
|
||||
|
||||
new KeyValuePair<string, CSharpDataType>("varchar",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("character varying",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("name",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("text",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("char",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("character",CSharpDataType.@string),
|
||||
|
@ -34,11 +34,20 @@ namespace SqlSugar
|
||||
return "select current_date";
|
||||
}
|
||||
}
|
||||
|
||||
public bool isAutoToLower
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings == null) return true;
|
||||
return this.Context.CurrentConnectionConfig.MoreSettings.PgSqlIsAutoToLower;
|
||||
}
|
||||
}
|
||||
public override string GetTranslationColumnName(string propertyName)
|
||||
{
|
||||
if (propertyName.Contains(SqlTranslationLeft)) return propertyName;
|
||||
else
|
||||
return SqlTranslationLeft + propertyName.ToLower() + SqlTranslationRight;
|
||||
return SqlTranslationLeft + propertyName.ToLower(isAutoToLower) + SqlTranslationRight;
|
||||
}
|
||||
|
||||
//public override string GetNoTranslationColumnName(string name)
|
||||
@ -55,7 +64,7 @@ namespace SqlSugar
|
||||
.FirstOrDefault(it =>
|
||||
it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase) &&
|
||||
it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
|
||||
return (mappingInfo == null ? SqlTranslationLeft + propertyName.ToLower() + SqlTranslationRight : SqlTranslationLeft + mappingInfo.DbColumnName.ToLower() + SqlTranslationRight);
|
||||
return (mappingInfo == null ? SqlTranslationLeft + propertyName.ToLower(isAutoToLower) + SqlTranslationRight : SqlTranslationLeft + mappingInfo.DbColumnName.ToLower(isAutoToLower) + SqlTranslationRight);
|
||||
}
|
||||
|
||||
public override string GetTranslationTableName(string name)
|
||||
@ -69,7 +78,7 @@ namespace SqlSugar
|
||||
name = (mappingInfo == null ? name : mappingInfo.DbTableName);
|
||||
if (name.Contains(".")&& !name.Contains("("))
|
||||
{
|
||||
return string.Join(".", name.ToLower().Split('.').Select(it => SqlTranslationLeft + it + SqlTranslationRight));
|
||||
return string.Join(".", name.ToLower(isAutoToLower).Split('.').Select(it => SqlTranslationLeft + it + SqlTranslationRight));
|
||||
}
|
||||
else if (name.Contains("("))
|
||||
{
|
||||
@ -81,7 +90,7 @@ namespace SqlSugar
|
||||
}
|
||||
else
|
||||
{
|
||||
return SqlTranslationLeft + name.ToLower().TrimEnd('"').TrimStart('"') + SqlTranslationRight;
|
||||
return SqlTranslationLeft + name.ToLower(isAutoToLower).TrimEnd('"').TrimStart('"') + SqlTranslationRight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,14 @@ namespace SqlSugar
|
||||
}
|
||||
public override string GetTranslationText(string name)
|
||||
{
|
||||
return SqlTranslationLeft + name.ToLower() + SqlTranslationRight;
|
||||
return SqlTranslationLeft + name.ToLower(isAutoToLower) + SqlTranslationRight;
|
||||
}
|
||||
public bool isAutoToLower
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.PgSqlIsAutoToLower;
|
||||
}
|
||||
}
|
||||
public override string GetTranslationTableName(string entityName, bool isMapping = true)
|
||||
{
|
||||
@ -46,7 +53,7 @@ namespace SqlSugar
|
||||
else if (isMapping)
|
||||
{
|
||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
|
||||
return SqlTranslationLeft + (mappingInfo == null ? entityName : mappingInfo.DbTableName).ToLower() + SqlTranslationRight;
|
||||
return SqlTranslationLeft + (mappingInfo == null ? entityName : mappingInfo.DbTableName).ToLower(isAutoToLower) + SqlTranslationRight;
|
||||
}
|
||||
else if (isComplex)
|
||||
{
|
||||
@ -79,11 +86,11 @@ namespace SqlSugar
|
||||
if (this.MappingColumns.HasValue())
|
||||
{
|
||||
var mappingInfo = this.MappingColumns.SingleOrDefault(it => it.EntityName == entityName && it.PropertyName == propertyName);
|
||||
return (mappingInfo == null ? propertyName : mappingInfo.DbColumnName).ToLower();
|
||||
return (mappingInfo == null ? propertyName : mappingInfo.DbColumnName).ToLower(isAutoToLower);
|
||||
}
|
||||
else
|
||||
{
|
||||
return propertyName.ToLower();
|
||||
return propertyName.ToLower(isAutoToLower);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,11 +75,11 @@ namespace SqlSugar
|
||||
{
|
||||
value = it.Value;
|
||||
}
|
||||
if (value == null)
|
||||
if (value == null||value==DBNull.Value)
|
||||
{
|
||||
return string.Format(SqlTemplateBatchSelect, "NULL");
|
||||
}
|
||||
return string.Format(SqlTemplateBatchSelect, "'" + value + "'");
|
||||
return string.Format(SqlTemplateBatchSelect, "'" + value.ObjToString().ToSqlFilter() + "'");
|
||||
})) + "),");
|
||||
++i;
|
||||
}
|
||||
|
@ -37,5 +37,12 @@ namespace SqlSugar
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
internal static string ToLower(this string value ,bool isAutoToLower)
|
||||
{
|
||||
if (value == null) return null;
|
||||
if (isAutoToLower == false) return value;
|
||||
return value.ToLower();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user