EF core 1.0.0 has ToListAsync(). I can see that EntityFrameworkDynamicQueryableExtensions class doesn't have this. Will there be a support on this in the future?
using (var context = new TestContext(_optionsBuilder.Options)) { var queryFirstNameContainsTest = context.Persons.Where(x => x.FirstName.Contains("test")); var test = await queryFirstNameContainsTest.Select("new (FirstName,LastName)").Cast<Person>().ToListAsync(); }
received this error
Test Name: WTW.TMS.Compensation.BasePay.Business.Tests.DynamicEFTests.DynamicEFSelectTest
Test FullName: WTW.TMS.Compensation.BasePay.Business.Tests.DynamicEFTests.DynamicEFSelectTest
Test Source: C:\Projects\Tests\DynamicEFTests.cs : line 26
Test Outcome: Failed
Test Duration: 0:00:08.22
Result StackTrace:
at System.Linq.Expressions.Expression.GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
at Remotion.Linq.Clauses.ResultOperators.CastResultOperator.GetOutputDataInfo(IStreamedDataInfo inputInfo)
at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable1 source, TAccumulate seed, Func3 func)
at Remotion.Linq.QueryModel.GetOutputDataInfo()
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.SingleResultToSequence(QueryModel queryModel, Type type)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateAsyncQueryExecutor[TResult](QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddAsyncQuery[TResult](Object cacheKey, Func1 compiler) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query) at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable1.System.Collections.Generic.IAsyncEnumerable.GetEnumerator()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.d__1291.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at Tests.DynamicEFTests.d__2.MoveNext() in C:\Projects\Tests\DynamicEFTests.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_0(Object state)
at Xunit.Sdk.AsyncTestSyncContext.<>c__DisplayClass7_0.b__1(Object _)
Result Message: No coercion operator is defined between types '<>f__AnonymousType0`2[System.String,System.String]' and 'Domain.Entities.Employee.Person'.
EF core 1.0.0 has ToListAsync(). I can see that EntityFrameworkDynamicQueryableExtensions class doesn't have this. Will there be a support on this in the future?
using (var context = new TestContext(_optionsBuilder.Options)) { var queryFirstNameContainsTest = context.Persons.Where(x => x.FirstName.Contains("test")); var test = await queryFirstNameContainsTest.Select("new (FirstName,LastName)").Cast<Person>().ToListAsync(); }received this error
Result StackTrace:
at System.Linq.Expressions.Expression.GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
at Remotion.Linq.Clauses.ResultOperators.CastResultOperator.GetOutputDataInfo(IStreamedDataInfo inputInfo)
at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable
1 source, TAccumulate seed, Func3 func)at Remotion.Linq.QueryModel.GetOutputDataInfo()
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.SingleResultToSequence(QueryModel queryModel, Type type)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateAsyncQueryExecutor[TResult](QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddAsyncQuery[TResult](Object cacheKey, Func
1 compiler) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query) at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable1.System.Collections.Generic.IAsyncEnumerable.GetEnumerator()at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.d__129
1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()at Tests.DynamicEFTests.d__2.MoveNext() in C:\Projects\Tests\DynamicEFTests.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_0(Object state)
at Xunit.Sdk.AsyncTestSyncContext.<>c__DisplayClass7_0.b__1(Object _)
Result Message: No coercion operator is defined between types '<>f__AnonymousType0`2[System.String,System.String]' and 'Domain.Entities.Employee.Person'.