This commit is contained in:
parent
c59194eb84
commit
b9e9713410
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using ShardingCore.Exceptions;
|
||||
using ShardingCore.Sharding.Abstractions;
|
||||
|
||||
|
@ -44,7 +46,17 @@ namespace ShardingCore.Extensions
|
|||
public static string FormatRouteTail2ModelCacheKey(this string originalTail)
|
||||
{
|
||||
return $"{ShardingTableDbContextFormat}{originalTail}";
|
||||
;
|
||||
}
|
||||
|
||||
public static string ShardingPrint(this Expression expression)
|
||||
{
|
||||
|
||||
#if !EFCORE2
|
||||
return expression.Print();
|
||||
#endif
|
||||
#if EFCORE2
|
||||
return expression.ToString();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,7 @@ namespace ShardingCore.Sharding.StreamMergeEngines.Abstractions
|
|||
{
|
||||
_methodCallExpression = methodCallExpression;
|
||||
var expression = methodCallExpression.Arguments.FirstOrDefault(o => typeof(IQueryable).IsAssignableFrom(o.Type))
|
||||
#if !EFCORE2
|
||||
?? throw new InvalidOperationException(methodCallExpression.Print());
|
||||
#endif
|
||||
#if EFCORE2
|
||||
?? throw new InvalidOperationException(methodCallExpression.ToString());
|
||||
#endif
|
||||
?? throw new InvalidOperationException(methodCallExpression.ShardingPrint());
|
||||
_queryable = new EnumerableQuery<TEntity>(expression);
|
||||
_secondExpression = methodCallExpression.Arguments.FirstOrDefault(o => !typeof(IQueryable).IsAssignableFrom(o.Type));
|
||||
|
||||
|
@ -48,12 +43,7 @@ namespace ShardingCore.Sharding.StreamMergeEngines.Abstractions
|
|||
{
|
||||
if (methodCallExpression.Arguments.Count == 2)
|
||||
{
|
||||
#if !EFCORE2
|
||||
throw new InvalidOperationException(methodCallExpression.Print());
|
||||
#endif
|
||||
#if EFCORE2
|
||||
throw new InvalidOperationException(methodCallExpression.ToString());
|
||||
#endif
|
||||
throw new InvalidOperationException(methodCallExpression.ShardingPrint());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,17 +44,6 @@ namespace ShardingCore.Sharding.StreamMergeEngines
|
|||
await enumator.MoveNextAsync();
|
||||
return enumator;
|
||||
}
|
||||
#endif
|
||||
#if EFCORE2
|
||||
private async Task<IAsyncEnumerator<T>> GetAsyncEnumerator(IQueryable<T> newQueryable)
|
||||
{
|
||||
var enumator = newQueryable.AsAsyncEnumerable().GetEnumerator();
|
||||
await enumator.MoveNext();
|
||||
return enumator;
|
||||
}
|
||||
#endif
|
||||
#if !EFCORE2
|
||||
|
||||
public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = new CancellationToken())
|
||||
{
|
||||
return GetShardingEnumerator();
|
||||
|
@ -62,6 +51,12 @@ namespace ShardingCore.Sharding.StreamMergeEngines
|
|||
#endif
|
||||
|
||||
#if EFCORE2
|
||||
private async Task<IAsyncEnumerator<T>> GetAsyncEnumerator(IQueryable<T> newQueryable)
|
||||
{
|
||||
var enumator = newQueryable.AsAsyncEnumerable().GetEnumerator();
|
||||
await enumator.MoveNext();
|
||||
return enumator;
|
||||
}
|
||||
IAsyncEnumerator<T> IAsyncEnumerable<T>.GetEnumerator()
|
||||
{
|
||||
return GetShardingEnumerator();
|
||||
|
|
Loading…
Reference in New Issue