修复group by时候的value null的bug 发布x.6.0.36
This commit is contained in:
parent
f58fb88c10
commit
1342d13eb3
|
@ -1,9 +1,9 @@
|
|||
:start
|
||||
::定义版本
|
||||
set EFCORE2=2.6.0.35
|
||||
set EFCORE3=3.6.0.35
|
||||
set EFCORE5=5.6.0.35
|
||||
set EFCORE6=6.6.0.35
|
||||
set EFCORE2=2.6.0.36
|
||||
set EFCORE3=3.6.0.36
|
||||
set EFCORE5=5.6.0.36
|
||||
set EFCORE6=6.6.0.36
|
||||
|
||||
::删除所有bin与obj下的文件
|
||||
@echo off
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace ShardingCore.Extensions
|
|||
.SetValue(t,value);
|
||||
}
|
||||
}
|
||||
public static object GetValueByExpression(this object obj, string propertyExpression)
|
||||
public static (Type propertyType,object value) GetValueByExpression(this object obj, string propertyExpression)
|
||||
{
|
||||
var entityType = obj.GetType();
|
||||
PropertyInfo property;
|
||||
|
@ -78,8 +78,8 @@ namespace ShardingCore.Extensions
|
|||
{
|
||||
throw new ShardingCoreException($"property:[{propertyExpression}] not in type:[{entityType}]");
|
||||
}
|
||||
|
||||
return property.GetValue(obj);
|
||||
|
||||
return (property.PropertyType,property.GetValue(obj));
|
||||
//var lambda = Expression.Lambda(propertyAccess, parameter);
|
||||
//Delegate fn = lambda.Compile();
|
||||
//return fn.DynamicInvoke(obj);
|
||||
|
|
|
@ -19,6 +19,11 @@ namespace ShardingCore.Extensions
|
|||
{
|
||||
return !type.IsValueType || (Nullable.GetUnderlyingType(type) != null);
|
||||
}
|
||||
|
||||
public static bool IsComparableType(this Type type)
|
||||
{
|
||||
return typeof(IComparable).IsAssignableFrom(type);
|
||||
}
|
||||
/// <summary>
|
||||
/// 检测是否是数字类型,包括nullable的数字类型
|
||||
/// </summary>
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace ShardingCore.Sharding.Enumerators
|
|||
{
|
||||
var first = enumerator.ReallyCurrent;
|
||||
return _mergeContext.SelectContext.SelectProperties.Where(o => !(o is SelectAggregateProperty))
|
||||
.Select(o => first.GetValueByExpression(o.PropertyName)).ToList();
|
||||
.Select(o => first.GetValueByExpression(o.PropertyName).value).ToList();
|
||||
}
|
||||
#if !EFCORE2
|
||||
public async ValueTask<bool> MoveNextAsync()
|
||||
|
@ -85,7 +85,7 @@ namespace ShardingCore.Sharding.Enumerators
|
|||
var current = GetCurrentGroupValues(_queue.Peek());
|
||||
for (int i = 0; i < CurrentGroupValues.Count; i++)
|
||||
{
|
||||
if (!CurrentGroupValues[i].Equals(current[i]))
|
||||
if (!object.Equals(CurrentGroupValues[i],current[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,11 +99,17 @@ namespace ShardingCore.Sharding.Enumerators
|
|||
var list = new List<IComparable>(_mergeContext.Orders.Count());
|
||||
foreach (var order in _mergeContext.Orders)
|
||||
{
|
||||
var value = _enumerator.ReallyCurrent.GetValueByExpression(order.PropertyExpression);
|
||||
var (propertyType,value) = _enumerator.ReallyCurrent.GetValueByExpression(order.PropertyExpression);
|
||||
if (value is IComparable comparable)
|
||||
list.Add(comparable);
|
||||
else if (propertyType.IsComparableType())
|
||||
{
|
||||
list.Add((IComparable)value);
|
||||
}
|
||||
else
|
||||
throw new NotSupportedException($"order by value [{order}] must implements IComparable");
|
||||
{
|
||||
throw new NotSupportedException($"order by value [{order}] must implements IComparable");
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
|
|
Loading…
Reference in New Issue