-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sqlite Support translation of ToString #17223
Comments
Is the following, the reason why it would not work as I expected? |
Sqlite provider does not have support for |
Ah, thanks for the answer! |
Assigning to @bricelam since PR is assigned to him. |
We use SQLite for our unit tests (and SQL Server for production) and it works great for the most part but I just hit an issue with converting numbers to strings and the workaround I found for that is to explicitly call ToString(), which then breaks all the relevant tests. The conversion issue is #20732 |
Passing to @maumar |
Resolves dotnet#17223
If there's a point release before 6.0.0 will this make it into that or will this definitely not land before 6.0.0? I did some ugly work arounds for this once and just hit another place it looks like I'll have to do that again and would really rather not. |
@jons-aura as this is a feature, we won't be backporting this to 5.0.x; we only patch for bugs. However, this will be out in a couple weeks as 6.0.0-preview1, and our previews are quite stable (undergo the same test verification suite etc.), and we react quickly to regressions found on them - so I'd consider using that. |
Describe what is not working as expected.
First, I am new to asp core and this may not be expected to work like that.
I am trying to convert an Id (int) to a string so I can use Contains method to search using a pattern. However, the code breaks when I have ToString used on int.
Query.Where(s => s.Id.ToString().Contains("something"));
Example of my code
materialQuery = materialQuery.Where(s => s.Name.ToLower().Contains(searchString.ToLower()) || s.Id.ToString().Contains(searchString));
If you are seeing an exception, include the full exceptions details (message and stack trace).
Exception has occurred: CLR/System.InvalidOperationException
An exception of type 'System.InvalidOperationException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Operation is not valid due to the current state of the object.'
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateWhere(ShapedQueryExpression source, LambdaExpression predicate)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass12_0
1.<ExecuteAsync>b__0() at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func
1 compiler)at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func
1 compiler) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo operatorMethodInfo, IQueryable
1 source, Expression expression, CancellationToken cancellationToken)at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ExecuteAsync[TSource,TResult](MethodInfo operatorMethodInfo, IQueryable
1 source, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.CountAsync[TSource](IQueryable
1 source, CancellationToken cancellationToken)at BAServer.Models.Helpers.PagedList
1.<CreateAsync>d__17.MoveNext() in /Users/codingaccountant/CodingAccountant/BAServer/Models/Helpers/PagedList.cs:line 29 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()at BAServer.Pages.IM.Master_Data.IndexMaterial.d__11.MoveNext() in /Users/codingaccountant/CodingAccountant/BAServer/Pages/IM/Master Data/IndexMaterial.razor:line 111
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at BAServer.Pages.IM.Master_Data.IndexMaterial.d__9.MoveNext() in /Users/codingaccountant/CodingAccountant/BAServer/Pages/IM/Master Data/IndexMaterial.razor:line 87
The text was updated successfully, but these errors were encountered: