Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 9dc4341

Browse files
committed
Minor fixes and refactoring.
1 parent a6e0076 commit 9dc4341

File tree

3 files changed

+12
-32
lines changed

3 files changed

+12
-32
lines changed

Source/LinqToDB.EntityFrameworkCore/Internal/LinqToDBForEFQueryProvider.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ TResult IAsyncQueryProvider.ExecuteAsync<TResult>(Expression expression, Cancell
6868

6969
public System.Collections.Generic.IAsyncEnumerable<TResult> ExecuteAsync<TResult>(Expression expression)
7070
{
71-
return new AsyncEnumerableAdaper<TResult>(QueryProvider.ExecuteAsync<TResult>(expression));
71+
return new AsyncEnumerableAdapter<TResult>(QueryProvider.ExecuteAsync<TResult>(expression));
7272
}
7373

7474
IAsyncEnumerable<TResult> IQueryProviderAsync.ExecuteAsync<TResult>(Expression expression)
@@ -99,38 +99,40 @@ IEnumerator IEnumerable.GetEnumerator()
9999

100100
#endregion
101101

102-
System.Collections.Generic.IAsyncEnumerator<T> System.Collections.Generic.IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationToken cancellationTokent)
102+
System.Collections.Generic.IAsyncEnumerator<T> System.Collections.Generic.IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationToken cancellationToken)
103103
{
104-
return ExecuteAsync<T>(Expression).GetAsyncEnumerator(CancellationToken.None);
104+
return ExecuteAsync<T>(Expression).GetAsyncEnumerator(cancellationToken);
105105
}
106106

107-
class AsyncEnumerableAdaper<TEntity> : System.Collections.Generic.IAsyncEnumerable<TEntity>
107+
class AsyncEnumerableAdapter<TEntity> : System.Collections.Generic.IAsyncEnumerable<TEntity>
108108
{
109109
private IAsyncEnumerable<TEntity> AsyncEnumerable { get; }
110110

111-
public AsyncEnumerableAdaper(IAsyncEnumerable<TEntity> asyncEnumerable)
111+
public AsyncEnumerableAdapter(IAsyncEnumerable<TEntity> asyncEnumerable)
112112
{
113113
AsyncEnumerable = asyncEnumerable;
114114
}
115115

116-
public System.Collections.Generic.IAsyncEnumerator<TEntity> GetAsyncEnumerator(CancellationToken cancellationToken = new CancellationToken())
116+
public System.Collections.Generic.IAsyncEnumerator<TEntity> GetAsyncEnumerator(CancellationToken cancellationToken = default)
117117
{
118-
return new AsyncEnumeratorAdapter<TEntity>(AsyncEnumerable.GetEnumerator());
118+
return new AsyncEnumeratorAdapter<TEntity>(AsyncEnumerable.GetEnumerator(), cancellationToken);
119119
}
120120
}
121121

122122
class AsyncEnumeratorAdapter<TEntity> : System.Collections.Generic.IAsyncEnumerator<TEntity>
123123
{
124+
private readonly CancellationToken _cancellationToken;
124125
private IAsyncEnumerator<TEntity> AsyncEnumerator { get; }
125126

126-
public AsyncEnumeratorAdapter(IAsyncEnumerator<TEntity> asyncEnumerator)
127+
public AsyncEnumeratorAdapter(IAsyncEnumerator<TEntity> asyncEnumerator, CancellationToken cancellationToken)
127128
{
128-
AsyncEnumerator = asyncEnumerator;
129+
_cancellationToken = cancellationToken;
130+
AsyncEnumerator = asyncEnumerator;
129131
}
130132

131133
public ValueTask<bool> MoveNextAsync()
132134
{
133-
return new ValueTask<bool>(AsyncEnumerator.MoveNext(CancellationToken.None));
135+
return new ValueTask<bool>(AsyncEnumerator.MoveNext(_cancellationToken));
134136
}
135137

136138
public TEntity Current => AsyncEnumerator.Current;

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.Mapping.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,6 @@ static void InitializeSqlServerMapping()
9292

9393
Linq.Expressions.MapMember(method, lambda);
9494
}
95-
96-
// var freeTextMethod = sqlServerMethods.FirstOrDefault(m => m.Name == "FreeText" && m.GetParameters().Length == 3);
97-
// if (freeTextMethod != null)
98-
// {
99-
// var propertyReferenceParam = Expression.Parameter(typeof(string), "propertyReference");
100-
// var freeTextParam = Expression.Parameter(typeof(string), "freeText");
101-
//
102-
// var lambda = Expression.Lambda(
103-
// Expression.Call(
104-
// MemberHelper.MethodOf(() => Sql.FreeText(null, null)),
105-
// propertyReferenceParam,
106-
// freeTextParam
107-
// ),
108-
// dbFunctionsParameter,
109-
// propertyReferenceParam,
110-
// freeTextParam
111-
// );
112-
//
113-
// Linq.Expressions.MapMember(freeTextMethod, lambda);
114-
// }
115-
11695
}
11796

11897
#endregion

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ static List<Expression> CompactTree(List<Expression> items, ExpressionType nodeT
576576
return result;
577577
}
578578

579-
580579
/// <summary>
581580
/// Transforms EF.Core expression tree to LINQ To DB expression.
582581
/// Method replaces EF.Core <see cref="EntityQueryable{TResult}"/> instances with LINQ To DB

0 commit comments

Comments
 (0)