Browse Source

Add WhereColumns(+2)

pull/20/head
sunkaixuan 2 years ago
parent
commit
cb3379e20c
  1. 19
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  2. 1
      Src/Asp.Net/SqlSugar/Interface/IQueryable.cs
  3. 6
      Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs

19
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -423,6 +423,25 @@ namespace SqlSugar
{ {
return WhereColumns(new List<Dictionary<string, object>> { dictionary }); 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) public ISugarQueryable<T> WhereColumns(List<Dictionary<string, object>> list)
{ {
List<IConditionalModel> conditionalModels = new List<IConditionalModel>(); List<IConditionalModel> conditionalModels = new List<IConditionalModel>();

1
Src/Asp.Net/SqlSugar/Interface/IQueryable.cs

@ -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, bool ignoreDefaultValue);
ISugarQueryable<T> WhereColumns(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);

6
Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs

@ -17,6 +17,12 @@ namespace SqlSugar
public class UtilMethods 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) internal static DateTime ConvertFromDateTimeOffset(DateTimeOffset dateTime)
{ {
if (dateTime.Offset.Equals(TimeSpan.Zero)) if (dateTime.Offset.Equals(TimeSpan.Zero))

Loading…
Cancel
Save