Skip to content

Commit ff4f679

Browse files
Async: messages and doc tags (#379)
1 parent 069dd26 commit ff4f679

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

net/DevExtreme.AspNet.Data/Async/ReflectionAsyncAdapter.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ MethodInfo GetCountAsyncMethod() {
3434
if(IsXPO)
3535
return XpoMethods.CountAsyncMethod;
3636

37-
throw NotSupported();
37+
throw ProviderNotSupported(provider);
3838
}
3939

4040
return InvokeCountAsync(GetCountAsyncMethod(), provider, expr, cancellationToken);
@@ -53,12 +53,18 @@ public Task<IEnumerable<T>> ToEnumerableAsync<T>(IQueryProvider provider, Expres
5353
if(IsXPO)
5454
return InvokeToArrayAsync<T>(XpoMethods.ToArrayAsyncMethod, provider, expr, cancellationToken);
5555

56-
throw NotSupported();
56+
throw ProviderNotSupported(provider);
5757
}
5858

59-
static Exception NotSupported() {
60-
#warning TODO message
61-
throw new NotSupportedException();
59+
static Exception ProviderNotSupported(IQueryProvider provider) {
60+
var providerType = provider.GetType();
61+
if(providerType.IsGenericType)
62+
providerType = providerType.GetGenericTypeDefinition();
63+
64+
var message = $"Async operations for the LINQ provider '{providerType.FullName}' are not supported."
65+
+ $" You can implement a custom async adapter ({typeof(IAsyncAdapter).FullName}) and register it via '{typeof(CustomAsyncAdapters).FullName}.{nameof(CustomAsyncAdapters.RegisterAdapter)}'.";
66+
67+
return new NotSupportedException(message);
6268
}
6369

6470
static class EF6Methods {

net/DevExtreme.AspNet.Data/DataSourceLoader.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,44 @@
88
namespace DevExtreme.AspNet.Data {
99

1010
/// <summary>
11-
/// Provides static methods for loading data from collections that implement the IEnumerable&lt;T&gt; or IQueryable&lt;T&gt; interface.
11+
/// Provides static methods for loading data from collections that implement the
12+
/// <see cref="System.Collections.Generic.IEnumerable{T}"/> or <see cref="System.Linq.IQueryable{T}"/> interface.
1213
/// </summary>
1314
public class DataSourceLoader {
1415

1516
/// <summary>
16-
/// Loads data from a collection that implements the IEnumerable&lt;T&gt; interface.
17+
/// Loads data from a collection that implements the <see cref="System.Collections.Generic.IEnumerable{T}"/> interface.
1718
/// </summary>
1819
/// <typeparam name="T">The type of objects in the collection.</typeparam>
19-
/// <param name="source">A collection that implements the IEnumerable&lt;T&gt; interface.</param>
20+
/// <param name="source">A collection that implements the <see cref="System.Collections.Generic.IEnumerable{T}"/> interface.</param>
2021
/// <param name="options">Data processing settings when loading data.</param>
2122
/// <returns>The load result.</returns>
2223
public static LoadResult Load<T>(IEnumerable<T> source, DataSourceLoadOptionsBase options) {
2324
return Load(source.AsQueryable(), options);
2425
}
2526

2627
/// <summary>
27-
/// Loads data from a collection that implements the IQueryable&lt;T&gt; interface.
28+
/// Loads data from a collection that implements the <see cref="System.Linq.IQueryable{T}"/> interface.
2829
/// </summary>
2930
/// <typeparam name="T">The type of objects in the collection.</typeparam>
30-
/// <param name="source">A collection that implements the IQueryable&lt;T&gt; interface.</param>
31+
/// <param name="source">A collection that implements the <see cref="System.Linq.IQueryable{T}"/> interface.</param>
3132
/// <param name="options">Data processing settings when loading data.</param>
3233
/// <returns>The load result.</returns>
3334
public static LoadResult Load<T>(IQueryable<T> source, DataSourceLoadOptionsBase options) {
3435
return LoadAsync(source, options, CancellationToken.None, true).GetAwaiter().GetResult();
3536
}
3637

38+
/// <summary>
39+
/// Asynchronously loads data from a collection that implements the <see cref="System.Linq.IQueryable{T}"/> interface.
40+
/// </summary>
41+
/// <typeparam name="T">The type of objects in the collection.</typeparam>
42+
/// <param name="source">A collection that implements the <see cref="System.Linq.IQueryable{T}"/> interface.</param>
43+
/// <param name="options">Data processing settings when loading data.</param>
44+
/// <param name="cancellationToken">A <see cref="System.Threading.CancellationToken"/> object that delivers a cancellation notice to the running operation.</param>
45+
/// <returns>
46+
/// A <see cref="System.Threading.Tasks.Task{TResult}"/> object that represents the asynchronous operation.
47+
/// The task result contains the load result.
48+
/// </returns>
3749
public static Task<LoadResult> LoadAsync<T>(IQueryable<T> source, DataSourceLoadOptionsBase options, CancellationToken cancellationToken = default(CancellationToken)) {
3850
return LoadAsync(source, options, cancellationToken, false);
3951
}

0 commit comments

Comments
 (0)