Update .net core project

This commit is contained in:
sunkaixuan
2022-07-06 17:27:23 +08:00
parent c3e1eee3be
commit 91ec10e704
7 changed files with 62 additions and 3 deletions

View File

@@ -58,6 +58,8 @@ namespace SqlSugar
foreach (var tableInfo in tableInfos)
{
TableDifferenceInfo addItem = new TableDifferenceInfo();
if (tableInfo.OldTableInfo == null)
tableInfo.OldTableInfo = new DbTableInfo();
addItem.TableName = tableInfo.OldTableInfo.Name;
addItem.AddColums = GetAddColumn(tableInfo);
addItem.UpdateColums = GetUpdateColumn(tableInfo);

View File

@@ -31,6 +31,36 @@ namespace SqlSugar
var result = updateable.Where(where).ExecuteCommand();
return result;
}
public int ExecuteCommand(string LogicFieldName, object deleteValue, string deleteTimeFieldName,string userNameFieldName,object userNameValue)
{
ISqlSugarClient db;
List<SugarParameter> pars;
string where;
LogicFieldName = _ExecuteCommand(LogicFieldName, out db, out where, out pars);
var updateable = db.Updateable<T>().SetColumns(LogicFieldName, deleteValue);
updateable.SetColumns(deleteTimeFieldName, DateTime.Now);
updateable.SetColumns(userNameFieldName,userNameValue);
if (pars != null)
updateable.UpdateBuilder.Parameters.AddRange(pars);
Convert(updateable as UpdateableProvider<T>);
var result = updateable.Where(where).ExecuteCommand();
return result;
}
public async Task<int> ExecuteCommandAsync(string LogicFieldName, object deleteValue, string deleteTimeFieldName, string userNameFieldName, object userNameValue)
{
ISqlSugarClient db;
List<SugarParameter> pars;
string where;
LogicFieldName = _ExecuteCommand(LogicFieldName, out db, out where, out pars);
var updateable = db.Updateable<T>().SetColumns(LogicFieldName, deleteValue);
updateable.SetColumns(deleteTimeFieldName, DateTime.Now);
updateable.SetColumns(userNameFieldName, userNameValue);
if (pars != null)
updateable.UpdateBuilder.Parameters.AddRange(pars);
Convert(updateable as UpdateableProvider<T>);
var result =await updateable.Where(where).ExecuteCommandAsync();
return result;
}
public async Task<int> ExecuteCommandAsync(string LogicFieldName = null, object deleteValue = null, string deleteTimeFieldName = null)
{
ISqlSugarClient db;

View File

@@ -423,6 +423,25 @@ namespace SqlSugar
{
return WhereColumns(new List<Dictionary<string, object>> { dictionary });
}
public ISugarQueryable<T> WhereColumns(Dictionary<string, object> columns, bool ignoreDefaultValue)
{
if (ignoreDefaultValue == false || columns == null)
{
return WhereColumns(columns);
}
else
{
var newColumns = new Dictionary<string, object>();
foreach (var item in columns)
{
if (!UtilMethods.IsDefaultValue(item.Value))
{
newColumns.Add(item.Key, item.Value);
}
}
return WhereColumns(newColumns);
}
}
public ISugarQueryable<T> WhereColumns(List<Dictionary<string, object>> list)
{
List<IConditionalModel> conditionalModels = new List<IConditionalModel>();

View File

@@ -54,6 +54,7 @@ namespace SqlSugar
ISugarQueryable<T> WhereClassByPrimaryKey(List<T> list);
ISugarQueryable<T> WhereClassByPrimaryKey(T data) ;
ISugarQueryable<T> WhereColumns(List<Dictionary<string, object>> columns);
ISugarQueryable<T> WhereColumns(Dictionary<string, object> columns, bool ignoreDefaultValue);
ISugarQueryable<T> WhereColumns(Dictionary<string, object> columns);
ISugarQueryable<T> TranLock(DbLockType LockType = DbLockType.Wait);
ISugarQueryable<T> Where(Expression<Func<T, bool>> expression);

View File

@@ -153,6 +153,10 @@ namespace SqlSugar
{
sqlParameter.DbType = System.Data.DbType.AnsiString;
}
else if (sqlParameter.Value is DateTime && sqlParameter.DbType == System.Data.DbType.AnsiString)
{
sqlParameter.DbType = System.Data.DbType.DateTime;
}
++index;
}
return result;

View File

@@ -14,11 +14,8 @@
</PropertyGroup>
<ItemGroup>
<Compile Remove="Abstract\AdoProvider\Abstract\**" />
<Compile Remove="dll\**" />
<EmbeddedResource Remove="Abstract\AdoProvider\Abstract\**" />
<EmbeddedResource Remove="dll\**" />
<None Remove="Abstract\AdoProvider\Abstract\**" />
<None Remove="dll\**" />
</ItemGroup>

View File

@@ -17,6 +17,12 @@ namespace SqlSugar
public class UtilMethods
{
internal static bool IsDefaultValue(object value)
{
if (value == null) return true;
return value.Equals(UtilMethods.GetDefaultValue(value.GetType()));
}
internal static DateTime ConvertFromDateTimeOffset(DateTimeOffset dateTime)
{
if (dateTime.Offset.Equals(TimeSpan.Zero))