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
Expression evaluation caused an overflow #13226
Comments
For SqlServer, it looks like we are eating up Convert node through RemoveConvert. We may/should introduce explicit cast. cc: @ErikEJ for SqlCE, Any leads based on exception message? |
@smitpatel I have improved type mapping of parameters on the latest SQL CE provider build, wonder if that would solve this? @SomPuttivara Could you share the generated SQL? And try 2.1.0.5 ? |
@ErikEJ Here is the generated SQL
This gets 'Expression evaluation caused an overflow. [ Name of function (if known) = ]' exception. I tried updating 0 to decimal: It generates:
I'm getting different exception: 'An exception occurred while reading a database value. The expected type was 'System.Decimal' but the actual value was of type 'System.Int32'.' Same happens when upgrading to 2.1.0.5 |
Discuss in triage 🇦🇺 |
@smitpatel @maumar @ErikEJ to look for workarounds |
Work-around var employee =
(from emp in dc.Employee
join dev in dc.EmployeeDevice
on emp.Id equals dev.EmployeeId
select new EmployeeInfo
{
EmployeeId = emp.Id,
EmployeeName = emp.Name,
Device = dev.Device,
AverageSharePerYear = emp.YearsOfService == 0 ? 0 : (1.0m * emp.NumberOfShare / emp.YearsOfService)
}).ToList();` |
The issue in SqlServer, eating up the cast to generate wrong result has been fixed in 3.0 release. Closing this issue as external. |
Background: I'm working on porting a legacy Linq2Sql solution to EFCore with @optiks
I'm getting an exception when having the following Linq query:
Steps to reproduce
Completed code can be found here:
https://github.com/avinash-phaniraj-readify/EFCoreTestBed/tree/ExpressionOverflow
While this is the behaviour we see with Sql CE, the SQL Server run has issues as well
On Sql Server not getting exception but the result is int. (returning 1 instead of 1.66666666666666666666) which is incorrect.
I found workaround to do this instead:
i.e use convert functions instead of casts.
Further technical details
EF Core version: 2.1.2
Database Provider: EntityFrameworkCore.SqlServerCompact35 2.1.0.1
Operating system: Windows 10
IDE: Visual Studio 2017 15.8
The text was updated successfully, but these errors were encountered: