Browse Source

Update .net

pull/12/head
sunkaixuna 3 years ago
parent
commit
796521730e
  1. 5
      Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs
  2. 23
      Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs
  3. 5
      Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs
  4. 5
      Src/Asp.Net/SqlSugar/Entities/DiffLogModel.cs
  5. 4
      Src/Asp.Net/SqlSugar/Realization/PostgreSQL/Insertable/PostgreSQLInserttable.cs
  6. 29
      Src/Asp.Net/SqlSugar/SqlSugar.csproj

5
Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs

@ -520,10 +520,13 @@ namespace SqlSugar
item.Columns = new List<DiffLogColumnInfo>();
foreach (DataColumn col in dt.Columns)
{
var sugarColumn = this.EntityInfo.Columns.Where(it => it.DbColumnName != null).First(it =>
it.DbColumnName.Equals(col.ColumnName, StringComparison.CurrentCultureIgnoreCase));
DiffLogColumnInfo addItem = new DiffLogColumnInfo();
addItem.Value = row[col.ColumnName];
addItem.ColumnName = col.ColumnName;
addItem.ColumnDescription = this.EntityInfo.Columns.Where(it=>it.DbColumnName!=null).First(it => it.DbColumnName.Equals(col.ColumnName, StringComparison.CurrentCultureIgnoreCase)).ColumnDescription;
addItem.IsPrimaryKey = sugarColumn.IsPrimarykey;
addItem.ColumnDescription = sugarColumn.ColumnDescription;
item.Columns.Add(addItem);
}
result.Add(item);

23
Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

@ -825,11 +825,13 @@ namespace SqlSugar
item.Columns = new List<DiffLogColumnInfo>();
foreach (DataColumn col in dt2.Columns)
{
var sugarColumn = this.EntityInfo.Columns.Where(it => it.DbColumnName != null).FirstOrDefault(it =>
it.DbColumnName.Equals(col.ColumnName, StringComparison.CurrentCultureIgnoreCase));
DiffLogColumnInfo addItem = new DiffLogColumnInfo();
addItem.Value = row[col.ColumnName];
addItem.ColumnName = col.ColumnName;
addItem.ColumnDescription = this.EntityInfo.Columns.Where(it => it.DbColumnName != null).FirstOrDefault(it => it.DbColumnName.Equals(col.ColumnName, StringComparison.CurrentCultureIgnoreCase))?.ColumnDescription;
addItem.IsPrimaryKey = sugarColumn?.IsPrimarykey ?? false;
addItem.ColumnDescription = sugarColumn?.ColumnDescription;
item.Columns.Add(addItem);
}
result.Add(item);
@ -846,6 +848,15 @@ namespace SqlSugar
if (identity != null && identity > 0 && GetIdentityKeys().HasValue())
{
var fieldName = GetIdentityKeys().Last();
if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL)
{
var fieldObjectType = this.EntityInfo.Columns.FirstOrDefault(x => x.DbColumnName == fieldName)
.PropertyInfo.PropertyType;
cons.Add(new ConditionalModel() { ConditionalType = ConditionalType.Equal, FieldName = fieldName, FieldValue = identity.ToString(),
FieldValueConvertFunc = it => UtilMethods.ChangeType2(it, fieldObjectType) });
}
else
cons.Add(new ConditionalModel() { ConditionalType = ConditionalType.Equal, FieldName = fieldName, FieldValue = identity.ToString() });
}
else
@ -880,10 +891,13 @@ namespace SqlSugar
item.Columns = new List<DiffLogColumnInfo>();
foreach (DataColumn col in dt.Columns)
{
var sugarColumn = this.EntityInfo.Columns.Where(it => it.DbColumnName != null).First(it =>
it.DbColumnName.Equals(col.ColumnName, StringComparison.CurrentCultureIgnoreCase));
DiffLogColumnInfo addItem = new DiffLogColumnInfo();
addItem.Value = row[col.ColumnName];
addItem.ColumnName = col.ColumnName;
addItem.ColumnDescription = this.EntityInfo.Columns.Where(it => it.DbColumnName != null).First(it => it.DbColumnName.Equals(col.ColumnName, StringComparison.CurrentCultureIgnoreCase)).ColumnDescription;
addItem.IsPrimaryKey = sugarColumn.IsPrimarykey;
addItem.ColumnDescription = sugarColumn.ColumnDescription;
item.Columns.Add(addItem);
}
result.Add(item);
@ -899,7 +913,8 @@ namespace SqlSugar
{
ColumnDescription = it.ColumnDescription,
ColumnName = it.DbColumnName,
Value = it.PropertyInfo.GetValue(this.InsertObjs.Last(), null)
Value = it.PropertyInfo.GetValue(this.InsertObjs.Last(), null),
IsPrimaryKey = it.IsPrimarykey
}).ToList();
return new List<DiffLogTableInfo>() { diffTable };
}

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

@ -856,10 +856,13 @@ namespace SqlSugar
item.Columns = new List<DiffLogColumnInfo>();
foreach (DataColumn col in dt.Columns)
{
var sugarColumn = this.EntityInfo.Columns.Where(it => it.DbColumnName != null).First(it =>
it.DbColumnName.Equals(col.ColumnName, StringComparison.CurrentCultureIgnoreCase));
DiffLogColumnInfo addItem = new DiffLogColumnInfo();
addItem.Value = row[col.ColumnName];
addItem.ColumnName = col.ColumnName;
addItem.ColumnDescription = this.EntityInfo.Columns.Where(it => it.DbColumnName != null).First(it => it.DbColumnName.Equals(col.ColumnName, StringComparison.CurrentCultureIgnoreCase)).ColumnDescription;
addItem.IsPrimaryKey = sugarColumn.IsPrimarykey;
addItem.ColumnDescription = sugarColumn.ColumnDescription;
item.Columns.Add(addItem);
}
result.Add(item);

5
Src/Asp.Net/SqlSugar/Entities/DiffLogModel.cs

@ -21,10 +21,11 @@ namespace SqlSugar
public string TableDescription { get; set; }
public List<DiffLogColumnInfo> Columns { get; set; }
}
public class DiffLogColumnInfo {
public class DiffLogColumnInfo
{
public string ColumnName { get; set; }
public string ColumnDescription { get; set; }
public object Value { get; set; }
public bool IsPrimaryKey { get; set; }
}
}

4
Src/Asp.Net/SqlSugar/Realization/PostgreSQL/Insertable/PostgreSQLInserttable.cs

@ -16,6 +16,7 @@ namespace SqlSugar
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey",this.SqlBuilder.GetTranslationColumnName(GetIdentityKeys().FirstOrDefault()));
RestoreMapping();
var result = Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()).ObjToInt();
After(sql, result);
return result;
}
public override async Task<int> ExecuteReturnIdentityAsync()
@ -26,6 +27,7 @@ namespace SqlSugar
RestoreMapping();
var obj = await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
var result = obj.ObjToInt();
After(sql, result);
return result;
}
public override KeyValuePair<string, List<SugarParameter>> ToSql()
@ -41,6 +43,7 @@ namespace SqlSugar
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", this.SqlBuilder.GetTranslationColumnName(GetIdentityKeys().FirstOrDefault()));
RestoreMapping();
var result = Convert.ToInt64(Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
After(sql, result);
return result;
}
public override async Task<long> ExecuteReturnBigIdentityAsync()
@ -50,6 +53,7 @@ namespace SqlSugar
string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", this.SqlBuilder.GetTranslationColumnName(GetIdentityKeys().FirstOrDefault()));
RestoreMapping();
var result = Convert.ToInt64(await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
After(sql, result);
return result;
}

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

@ -98,10 +98,39 @@
<Compile Include="Abstract\SugarProvider\SqlSugarCoreProvider.cs" />
<Compile Include="ExpressionsToSql\Subquery\SubTemplate.cs" />
<Compile Include="ExpressionsToSql\Subquery\SubqueryableN.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