This commit is contained in:
parent
9ca0507e1e
commit
57d11dff5a
|
@ -1,8 +1,8 @@
|
|||
:start
|
||||
::定义版本
|
||||
set EFCORE2=2.3.1.29
|
||||
set EFCORE3=3.3.1.29
|
||||
set EFCORE5=5.3.1.29
|
||||
set EFCORE2=2.3.1.30
|
||||
set EFCORE3=3.3.1.30
|
||||
set EFCORE5=5.3.1.30
|
||||
|
||||
::删除所有bin与obj下的文件
|
||||
@echo off
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace ShardingCore.Extensions
|
|||
}
|
||||
else
|
||||
{
|
||||
var comparer = Activator.CreateInstance(typeof(InMemoryShardingComparer<>).GetGenericType0(selectorResultType), shardingComparer);
|
||||
var comparer = shardingComparer.CreateComparer(selectorResultType);
|
||||
resultExp = Expression.Call(typeof(Queryable), methodName,
|
||||
new Type[] { type, selectorResultType },
|
||||
source.Expression, Expression.Quote(selector),Expression.Constant(comparer));
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace ShardingCore.Sharding.Abstractions
|
|||
public interface IShardingComparer
|
||||
{
|
||||
int Compare(IComparable a, IComparable b,bool asc);
|
||||
object CreateComparer(Type comparerType);
|
||||
}
|
||||
|
||||
public interface IShardingComparer<TShardingDbContext> : IShardingComparer where TShardingDbContext:DbContext,IShardingDbContext
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ShardingCore.Extensions;
|
||||
using ShardingCore.Sharding.Abstractions;
|
||||
using ShardingCore.Sharding.Internals;
|
||||
|
||||
namespace ShardingCore.Sharding
|
||||
{
|
||||
|
@ -13,9 +15,18 @@ namespace ShardingCore.Sharding
|
|||
*/
|
||||
public class CSharpLanguageShardingComparer<TShardingDbContext>:IShardingComparer<TShardingDbContext> where TShardingDbContext:DbContext,IShardingDbContext
|
||||
{
|
||||
private readonly ConcurrentDictionary<Type, object> _comparers = new ConcurrentDictionary<Type, object>();
|
||||
public int Compare(IComparable x, IComparable y, bool asc)
|
||||
{
|
||||
return x.SafeCompareToWith(y, asc);
|
||||
}
|
||||
|
||||
public object CreateComparer(Type comparerType)
|
||||
{
|
||||
var comparer = _comparers.GetOrAdd(comparerType,
|
||||
key => Activator.CreateInstance(typeof(InMemoryShardingComparer<>).GetGenericType0(comparerType),
|
||||
this));
|
||||
return comparer;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue