Browse Source

Update .net

pull/10/head
sunkaixuna 3 years ago
parent
commit
b54865d54b
  1. 4
      Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/LogicDeleteProvider.cs
  2. 2
      Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs
  3. 5
      Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastBuilder.cs
  4. 2
      Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs
  5. 9
      Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs
  6. 6
      Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlFastBuilder.cs
  7. 2
      Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs
  8. 4
      Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLQueryBuilder.cs
  9. 1
      Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerBlukCopy.cs
  10. 29
      Src/Asp.Net/SqlSugar/SqlSugar.csproj

4
Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/LogicDeleteProvider.cs

@ -17,11 +17,11 @@ namespace SqlSugar
List<SugarParameter> pars;
string where;
LogicFieldName = _ExecuteCommand(LogicFieldName, out db, out where, out pars);
var updateable = db.Updateable<T>().SetColumns(LogicFieldName, "@IsDeleted");
var updateable = db.Updateable<T>().SetColumns(LogicFieldName,true);
if (pars != null)
updateable.UpdateBuilder.Parameters.AddRange(pars);
Convert(updateable as UpdateableProvider<T>);
var result = updateable.Where(where, new { IsDeleted = true }).ExecuteCommand();
var result = updateable.Where(where).ExecuteCommand();
return result;
}
public async Task<int> ExecuteCommandAsync(string LogicFieldName = null)

2
Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs

@ -37,7 +37,7 @@ namespace SqlSugar
result.IsDisabledUpdateAll = sugarTable.IsDisabledUpdateAll;
result.IsDisabledDelete = sugarTable.IsDisabledDelete;
}
if (this.Context.Context.CurrentConnectionConfig.ConfigureExternalServices != null && this.Context.CurrentConnectionConfig.ConfigureExternalServices.EntityNameService != null)
if (this.Context.CurrentConnectionConfig.ConfigureExternalServices != null && this.Context.CurrentConnectionConfig.ConfigureExternalServices.EntityNameService != null)
{
if (result.DbTableName == null)
{

5
Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastBuilder.cs

@ -27,10 +27,11 @@ namespace SqlSugar
public virtual async Task<int> UpdateByTempAsync(string tableName, string tempName, string[] updateColumns, string[] whereColumns)
{
var sqlbuilder = this.Context.Queryable<object>().SqlBuilder;
Check.ArgumentNullException(!updateColumns.Any(), "update columns count is 0");
Check.ArgumentNullException(!whereColumns.Any(), "where columns count is 0");
var sets = string.Join(",", updateColumns.Select(it => $"TM.{it}=TE.{it}"));
var wheres = string.Join(",", whereColumns.Select(it => $"TM.{it}=TE.{it}"));
var sets = string.Join(",", updateColumns.Select(it => $"TM.{sqlbuilder.GetTranslationColumnName(it)}=TE.{sqlbuilder.GetTranslationColumnName(it)}"));
var wheres = string.Join(",", whereColumns.Select(it => $"TM.{sqlbuilder.GetTranslationColumnName(it)}=TE.{sqlbuilder.GetTranslationColumnName(it)}"));
string sql = string.Format(UpdateSql, sets, tableName, tempName, wheres);
return await this.Context.Ado.ExecuteCommandAsync(sql);
}

2
Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs

@ -80,6 +80,8 @@ namespace SqlSugar
private async Task<int> _BulkUpdate(List<T> datas, string[] whereColumns, string[] updateColumns)
{
Begin(datas);
Check.Exception(whereColumns == null || whereColumns.Count() == 0, "where columns count=0 or need primary key");
Check.Exception(updateColumns == null || updateColumns.Count() == 0, "set columns count=0");
var isAuto = this.context.CurrentConnectionConfig.IsAutoCloseConnection;
this.context.CurrentConnectionConfig.IsAutoCloseConnection = false;
DataTable dt = ToDdateTable(datas);

9
Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs

@ -299,7 +299,14 @@ namespace SqlSugar
{
fieldName = columnInfo.DbColumnName;
}
UpdateBuilder.SetValues.Add(new KeyValuePair<string, string>(fieldName, fieldValue+""));
var parameterName =this.SqlBuilder.SqlParameterKeyWord+ "Const" + this.UpdateBuilder.LambdaExpressions.ParameterIndex;
this.UpdateBuilder.LambdaExpressions.ParameterIndex = this.UpdateBuilder.LambdaExpressions.ParameterIndex+1;
if (UpdateBuilder.Parameters == null)
{
UpdateBuilder.Parameters = new List<SugarParameter>();
}
UpdateBuilder.Parameters.Add(new SugarParameter(parameterName, fieldValue));
UpdateBuilder.SetValues.Add(new KeyValuePair<string, string>(SqlBuilder.GetTranslationColumnName(fieldName), $"{SqlBuilder.GetTranslationColumnName(fieldName)}={parameterName}"));
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => (UpdateParameterIsNull == false && IsPrimaryKey(it)) || UpdateBuilder.SetValues.Any(v => SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.DbColumnName, StringComparison.CurrentCultureIgnoreCase) || SqlBuilder.GetNoTranslationColumnName(v.Key).Equals(it.PropertyName, StringComparison.CurrentCultureIgnoreCase)) || it.IsPrimarykey == true).ToList();
AppendSets();
return this;

6
Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlFastBuilder.cs

@ -44,7 +44,7 @@ namespace SqlSugar
TableName = dt.TableName,
Local = true,
};
bulk.Columns.AddRange(dt.Columns.Cast<DataColumn>().Select(colum => colum.ColumnName).Distinct().ToArray());
bulk.Columns.AddRange(dt.Columns.Cast<DataColumn>().Select(colum =>new MySqlBuilder().GetTranslationColumnName(colum.ColumnName)).Distinct().ToArray());
result= await bulk.LoadAsync();
//执行成功才删除文件
if (File.Exists(fileName))
@ -64,8 +64,10 @@ namespace SqlSugar
}
public override async Task CreateTempAsync<T>(DataTable dt)
{
var queryable = this.Context.Queryable<T>();
var tableName = queryable.SqlBuilder.GetTranslationTableName(dt.TableName);
dt.TableName = "temp"+SnowFlakeSingle.instance.getID();
var sql = this.Context.Queryable<T>().Select("*").Where(it => false).ToSql().Key;
var sql = queryable.AS(tableName).Where(it => false).ToSql().Key;
await this.Context.Ado.ExecuteCommandAsync($"Create TEMPORARY table {dt.TableName}({sql}) ");
}
}

2
Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs

@ -59,7 +59,7 @@ namespace SqlSugar
{
return Convert.ToInt64(value);
}
else if (type.IsIn(UtilConstants.IntType,UtilConstants.LongType,UtilConstants.ShortType))
else if (type.IsIn(UtilConstants.IntType,UtilConstants.LongType,UtilConstants.ShortType))
{
return value;
}

4
Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLQueryBuilder.cs

@ -85,6 +85,10 @@ namespace SqlSugar
{
this.SelectCacheKey = this.SelectCacheKey + string.Join("-", this.JoinQueryInfos.Select(it => it.TableName));
}
if (IsDistinct)
{
result = "distinct "+result;
}
return result;
}
}

1
Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerBlukCopy.cs

@ -115,6 +115,7 @@ namespace SqlSugar
{
this.Context.Ado.Connection.Open();
}
copy.BulkCopyTimeout = this.Context.Ado.CommandTimeOut;
return copy;
}
private DataTable GetCopyData()

29
Src/Asp.Net/SqlSugar/SqlSugar.csproj

@ -93,10 +93,39 @@
<Compile Include="Abstract\FastestProvider\Private.cs" />
<Compile Include="Abstract\FastestProvider\Setting.cs" />
<Compile Include="Abstract\FilterProvider\FilterProvider.cs" />
<Compile Include="Infrastructure\DependencyManagement.cs" />
<Compile Include="Interface\IFastBuilder.cs" />
<Compile Include="Interface\IFastest.cs" />
<Compile Include="OnlyNet\OracleFastBuilder.cs" />
<Compile Include="Realization\Kdbndp\CodeFirst\KdbndpCodeFirst.cs" />
<Compile Include="Realization\Kdbndp\DbBind\KdbndpBind.cs" />
<Compile Include="Realization\Kdbndp\DbFirst\KdbndpDbFirst.cs" />
<Compile Include="Realization\Kdbndp\DbMaintenance\KdbndpDbMaintenance.cs" />
<Compile Include="Realization\Kdbndp\Insertable\KdbndpInserttable.cs" />
<Compile Include="Realization\Kdbndp\KdbndpSQLProvider.cs" />
<Compile Include="Realization\Kdbndp\Queryable\KdbndpQueryable.cs" />
<Compile Include="Realization\Kdbndp\SqlBuilder\KdbndpBuilder.cs" />
<Compile Include="Realization\Kdbndp\SqlBuilder\KdbndpDeleteBuilder.cs" />
<Compile Include="Realization\Kdbndp\SqlBuilder\KdbndpExpressionContext.cs" />
<Compile Include="Realization\Kdbndp\SqlBuilder\KdbndpInsertBuilder.cs" />
<Compile Include="Realization\Kdbndp\SqlBuilder\KdbndpQueryBuilder.cs" />
<Compile Include="Realization\Kdbndp\SqlBuilder\KdbndpUpdateBuilder.cs" />
<Compile Include="Realization\MySql\SqlBuilder\MySqlFastBuilder.cs" />
<Compile Include="Realization\Oracle\SqlBuilder\OracleBlukCopy.cs" />
<Compile Include="Realization\Oracle\SqlBuilder\OracleFastBuilder.cs" />
<Compile Include="Realization\Oscar\CodeFirst\OscarCodeFirst.cs" />
<Compile Include="Realization\Oscar\DbBind\OscarDbBind.cs" />
<Compile Include="Realization\Oscar\DbFirst\OscarDbFirst.cs" />
<Compile Include="Realization\Oscar\DbMaintenance\OscarDbMaintenance.cs" />
<Compile Include="Realization\Oscar\Insertable\OscarInserttable.cs" />
<Compile Include="Realization\Oscar\OscarProvider.cs" />
<Compile Include="Realization\Oscar\Queryable\OscarQueryable.cs" />
<Compile Include="Realization\Oscar\SqlBuilder\OscarBuilder.cs" />
<Compile Include="Realization\Oscar\SqlBuilder\OscarDeleteBuilder.cs" />
<Compile Include="Realization\Oscar\SqlBuilder\OscarExpressionContext.cs" />
<Compile Include="Realization\Oscar\SqlBuilder\OscarInsertBuilder.cs" />
<Compile Include="Realization\Oscar\SqlBuilder\OscarQueryBuilder.cs" />
<Compile Include="Realization\Oscar\SqlBuilder\OscarUpdateBuilder.cs" />
<Compile Include="Realization\PostgreSQL\SqlBuilder\PostgreSQLFastBuilder.cs" />
<Compile Include="Realization\SqlServer\SqlBuilder\SqlServerFastBuilder.cs" />
<Compile Include="SpliteTable\SplitTableAttribute.cs" />

Loading…
Cancel
Save