OverflowException when querying decimal (38, 0) through LINQ To SQL - by JensS

Status : 

  External<br /><br />
		This item may be valid but belongs to an external system out of the direct control of this product team.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 316993 Comments
Status Closed Workarounds
Type Bug Repros 3
Opened 12/12/2007 12:26:22 AM
Access Restriction Public


When querying a field through LINQ To SQL that is a decimal (38,0) in a SQL table, we get an OverflowException.  This is most likely caused by the already recorded bug 96538.
Sign in to post a comment.
Posted by Diego [MSFT] on 10/17/2008 at 3:01 AM
In addition, we have added this to the internal list of suggestions that we track for future versions, in case can find an acceptable workaround.

Thanks again,
LINQ to SQL Team
Posted by Diego [MSFT] on 10/17/2008 at 2:58 AM

Thanks again for posting this. We are aware that the matching between the type systems is not perfect. We have analyzed this case, and have determined that we cannot handle this case in a special way in LINQ to SQL without negatively affecting the behavior of the great majority of cases in which decimal is a good fit for the server type.

LINQ to SQL Team
Posted by JensS on 5/19/2008 at 2:44 AM
I see that the bug was closed on may 14th without any explanation. As I don't know why the bug was closed and since the problem still is not fixed (even if the fix would be in VS.NET 2008 SP1, that is still in beta) I'm reopening it again.
Posted by JensS on 3/5/2008 at 5:34 AM
So after providing me with the info that I have knwo for quite some time, what are you guys going to do aboout it ?
If you'de look at the comments of bug 96538, you'd see that MS has been dancign around this problem at least since 08 Jan 2004 (which means more than 4 years). Don't you guys think it might be time to actually try to do something about this ?
When creating the mapping you guys could inspect the definition of the field and make LINQ map to a double instead of decimal.
Anyway, I don't care how you do it, but please, FIX THIS.
Posted by Faisal [MSFT] on 2/15/2008 at 11:35 AM

This is a bit unfortunate - but the behavior here is the result of the fact that the CLR Decimal type doesn't support enough precision to be able to handle everything that the SQL Decimal type can support. The maximum precision that is supported for mapping is DECIMAL(29).

You can do manual cast to a Double to go bigger when querying - but you will probably run into other issues because of the fact that there isn't perfect fidelity between the two type systems here.

LINQ to SQL Team
Posted by Microsoft on 12/12/2007 at 10:52 PM
Thanks for your feedback.

We are escalating this issue to the appropriate group within the Visual Studio Product Team for triage and resolution.
These specialized experts will follow-up with your issue.

Thank you,
Visual Studio Product Team
Posted by Microsoft on 12/12/2007 at 5:39 PM
Thank you for your feedback. We are currently investigating. The investigation process normally takes 7-14 days. If this issue is urgent, please contact support directly (see http://support.microsoft.com).

If at any time your issue is closed unsatisfactorily, you may edit your issue via Connect and change the status to “Active.”

Thank you,
Visual Studio Product Team