You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But if I try to add a cancellation token it ceases to compile because of CS0029 (Cannot implicitly convert ConfiguredCancelableAsyncEnumerable to IAsyncEnumerable):
publicinterfaceIMyService{Task<IAsyncEnumerable<Order>>GetOrdersInUserCity(intuserId,CancellationTokencancellationToken);}publicclassMyService(MyContextmyContext):IMyService{publicasyncTask<IAsyncEnumerable<Order>>GetOrdersInUserCity(intuserId,CancellationTokencancellationToken){varauxiliaryData=awaitmyContext.Users.FirstAsync(x =>x.UserId==userId,cancellationToken);// CompilesreturnmyContext.Orders.Where(x =>x.CityId==auxiliaryData.CityId).AsAsyncEnumerable().WithCancellationToken(cancellationToken);// Does not compile}}// EDIT: Should be:// public interface IMyService// {// IAsyncEnumerable<Order> GetOrdersInUserCity(int userId, CancellationToken cancellationToken); // No Task<>// }// public class MyService(MyContext myContext) : IMyService// {// public async IAsyncEnumerable<Order> GetOrdersInUserCity(int userId, [EnumeratorCancellation] CancellationToken cancellationToken) // [EnumeratorCancellation] attribute// {// var auxiliaryData = await myContext.Users.FirstAsync(x => x.UserId == userId, cancellationToken);// await foreach (var order in myContext.Orders.Where(x => x.CityId == auxiliaryData.CityId).AsAsyncEnumerable().WithCancellationToken(cancellationToken)) // Iterator// {// yield return order;// }// }// }
Pardon my ignorance, but how can I convert ConfiguredCancelableAsyncEnumerable back to IAsyncEnumerable? Is it 'not supposed' to be used this way😅?
The text was updated successfully, but these errors were encountered:
This class works fine:
But if I try to add a cancellation token it ceases to compile because of CS0029 (Cannot implicitly convert ConfiguredCancelableAsyncEnumerable to IAsyncEnumerable):
Pardon my ignorance, but how can I convert ConfiguredCancelableAsyncEnumerable back to IAsyncEnumerable? Is it 'not supposed' to be used this way😅?
The text was updated successfully, but these errors were encountered: