修复成员变量强转类型导致无法路由,并且发布x.4.2.10
This commit is contained in:
parent
54bdf3ff07
commit
fa9316a718
|
@ -1,9 +1,9 @@
|
|||
:start
|
||||
::定义版本
|
||||
set EFCORE2=2.4.2.09
|
||||
set EFCORE3=3.4.2.09
|
||||
set EFCORE5=5.4.2.09
|
||||
set EFCORE6=6.4.2.09
|
||||
set EFCORE2=2.4.2.10
|
||||
set EFCORE3=3.4.2.10
|
||||
set EFCORE5=5.4.2.10
|
||||
set EFCORE6=6.4.2.10
|
||||
|
||||
::删除所有bin与obj下的文件
|
||||
@echo off
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace ShardingCore.Core.Internal.Visitors
|
|||
{
|
||||
if (expression is MemberExpression member)
|
||||
{
|
||||
if (member.Expression.Type == _entityMetadata.EntityType)
|
||||
if (member.Expression.Type == _entityMetadata.EntityType|| MemberExpressionIsConvertAndOriginalIsEntityType(member))
|
||||
{
|
||||
var isShardingKey = false;
|
||||
if (_shardingTableRoute)
|
||||
|
@ -99,6 +99,17 @@ namespace ShardingCore.Core.Internal.Visitors
|
|||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 成员表达式是强转并且强转前的类型是当前对象
|
||||
/// </summary>
|
||||
/// <param name="member"></param>
|
||||
/// <returns></returns>
|
||||
private bool MemberExpressionIsConvertAndOriginalIsEntityType(MemberExpression member)
|
||||
{
|
||||
return member.Expression.NodeType == ExpressionType.Convert &&
|
||||
member.Expression is UnaryExpression unaryExpression &&
|
||||
unaryExpression.Operand.Type == _entityMetadata.EntityType;
|
||||
}
|
||||
/// <summary>
|
||||
/// 方法是否包含shardingKey xxx.invoke(shardingkey) eg. <code>o=>new[]{}.Contains(o.Id)</code>
|
||||
/// </summary>
|
||||
/// <param name="methodCallExpression"></param>
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace ShardingCore.Test.Domain.Entities
|
|||
* @Date: Thursday, 14 January 2021 15:36:43
|
||||
* @Email: 326308290@qq.com
|
||||
*/
|
||||
public class SysUserMod
|
||||
public class SysUserMod: IId
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户Id用于分表
|
||||
|
@ -21,6 +21,12 @@ namespace ShardingCore.Test.Domain.Entities
|
|||
/// </summary>
|
||||
public int Age { get; set; }
|
||||
public int AgeGroup { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public interface IId
|
||||
{
|
||||
string Id { get; set; }
|
||||
}
|
||||
|
||||
}
|
|
@ -536,7 +536,7 @@ namespace ShardingCore.Test
|
|||
[Fact]
|
||||
public async Task ToList_Id_Eq_Not_In_Db_Test()
|
||||
{
|
||||
var mod1s = await _virtualDbContext.Set<SysUserMod>().Where(o =>string.Compare(o.Id,"1001") ==0).ToListAsync();
|
||||
var mod1s = await _virtualDbContext.Set<SysUserMod>().Where(o =>string.Compare(((IId)o).Id,"1001") ==0).ToListAsync();
|
||||
var mod2s = await _virtualDbContext.Set<SysUserMod>().Where(o => string.Compare("1001", o.Id) == 0).ToListAsync();
|
||||
var mod3s = await _virtualDbContext.Set<SysUserMod>().Where(o => "1001".CompareTo(o.Id)==0).ToListAsync();
|
||||
var mod4s = await _virtualDbContext.Set<SysUserMod>().Where(o => o.Id.CompareTo("1001") == 0).ToListAsync();
|
||||
|
|
Loading…
Reference in New Issue