Update .net core project

This commit is contained in:
sunkaixuan 2022-07-05 01:59:35 +08:00
parent 25e053f8ad
commit b1ccb6b37c
5 changed files with 24 additions and 4 deletions

View File

@ -419,6 +419,10 @@ namespace SqlSugar
} }
return this; return this;
} }
public ISugarQueryable<T> WhereColumns(Dictionary<string, object> dictionary)
{
return WhereColumns(new List<Dictionary<string, object>> { dictionary });
}
public ISugarQueryable<T> WhereColumns(List<Dictionary<string, object>> list) public ISugarQueryable<T> WhereColumns(List<Dictionary<string, object>> list)
{ {
List<IConditionalModel> conditionalModels = new List<IConditionalModel>(); List<IConditionalModel> conditionalModels = new List<IConditionalModel>();
@ -432,7 +436,7 @@ namespace SqlSugar
{ {
FieldName = item, FieldName = item,
ConditionalType = ConditionalType.Equal, ConditionalType = ConditionalType.Equal,
FieldValue = model[item].ObjToString(), FieldValue = model[item]==null?"null" : model[item].ObjToString(),
CSharpTypeName = model[item] == null ? null : model[item].GetType().Name CSharpTypeName = model[item] == null ? null : model[item].GetType().Name
})); }));
i++; i++;

View File

@ -331,7 +331,7 @@ namespace SqlSugar
FieldName = item.DbColumnName, FieldName = item.DbColumnName,
ConditionalType = ConditionalType.Equal, ConditionalType = ConditionalType.Equal,
CSharpTypeName=UtilMethods.GetTypeName(value), CSharpTypeName=UtilMethods.GetTypeName(value),
FieldValue = value + "", FieldValue = value==null?"null":value.ObjToString(),
FieldValueConvertFunc=this.Context.CurrentConnectionConfig.DbType==DbType.PostgreSQL? FieldValueConvertFunc=this.Context.CurrentConnectionConfig.DbType==DbType.PostgreSQL?
UtilMethods.GetTypeConvert(value):null UtilMethods.GetTypeConvert(value):null
})); }));

View File

@ -164,8 +164,19 @@ namespace SqlSugar
switch (item.ConditionalType) switch (item.ConditionalType)
{ {
case ConditionalType.Equal: case ConditionalType.Equal:
if (item.FieldValue!=null&&item.FieldValue == "null"&&item.FieldValue!= "[null]")
{
builder.AppendFormat($" {item.FieldName.ToSqlFilter()} is null ");
}
else
{
if (item.FieldValue == "[null]")
{
item.FieldValue = "null";
}
builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "=", parameterName); builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "=", parameterName);
parameters.Add(new SugarParameter(parameterName, GetFieldValue(item))); parameters.Add(new SugarParameter(parameterName, GetFieldValue(item)));
}
break; break;
case ConditionalType.Like: case ConditionalType.Like:
builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "LIKE", parameterName); builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "LIKE", parameterName);

View File

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

View File

@ -176,6 +176,10 @@ namespace SqlSugar
{ {
sb.Append(row[colum].ObjToDate().ToString("yyyy-MM-dd HH:mm:ss.fff")); sb.Append(row[colum].ObjToDate().ToString("yyyy-MM-dd HH:mm:ss.fff"));
} }
else if (colum.DataType == UtilConstants.DateType && row[colum] != null && row[colum] == DBNull.Value)
{
sb.Append("NULL");
}
else sb.Append(row[colum].ToString()); else sb.Append(row[colum].ToString());
} }
sb.AppendLine(); sb.AppendLine();