2

Closed

large integer filter support

description

When I filter for a large number, such as 5049903980094673, the query submitted sets the last digit to 0 so the number becomes 5049903980094670. I tried using long and decimal mappings with same results. If I set the entity mapping to string then the value takes on decimal notation 5.04990398009467E+15 which doesn't return proper results.

A large integer like 5049903980094673 needs to be submitted to the database without value changes or scientific notation. Using TGH 1.0.15.279 connected to Oracle 11g.

Thanks!
Closed Dec 15, 2012 at 1:10 PM by Luis_Fernando

comments

Luis_Fernando wrote Oct 25, 2012 at 5:04 PM

Do you know what would be the best matching column type to build a test in SQLServer 2012?

Noyabronok wrote Oct 25, 2012 at 6:14 PM

It's a NUMBER in Oracle, and according to this page http://msdn.microsoft.com/en-us/library/ms151817.aspx it maps to FLOAT, but I don't think that's a good idea. This the the values are all whole numbers I would choose NUMERIC(38)

Thanks Luis.

Luis_Fernando wrote Oct 30, 2012 at 11:17 PM

The problem is not in the database.

Internally TGH uses "Convert.ChangeType(obj, objType)" to resolve values ​​coming from the user interface, "obj" is the value that comes from Telerik.GridCommand as a double (and we have no control over it), so in this case we are converting from double to decimal or long, when the conversion occurs, the value ends up losing precision in large numbers. Some important details about .NET's numbers precision on this response from Jon Skeet: http://stackoverflow.com/a/8284292/401576

I'm still after a less invasive solution, but until then I have a suggestion for you; ValueResolver to the rescue!

public class DecimalValueResolver : IValueResolver
{
public object Resolve(ResultContext source)
{
    var s = ((double)source.Value).ToString("R");
    var d = Decimal.Parse(s, NumberStyles.Currency);
    return d;
}
}

This will preserve precision in large numbers, hope it can help you for now, tell me if you have a better idea.

Luis_Fernando wrote Oct 31, 2012 at 12:59 AM

I think I'm approaching a coherent solution after reading this answer (http://stackoverflow.com/a/611564/401576) and this docs (http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx?ppud=4).

Luis_Fernando wrote Oct 31, 2012 at 1:09 AM

I just push a new commit with a possible solution;

http://tgh.codeplex.com/SourceControl/changeset/f9a1ba7dc6c8

Nugets and binaries tomorrow.

Luis_Fernando wrote Nov 18, 2012 at 9:57 PM

It's solved? Can I close the issue?

Noyabronok wrote Nov 21, 2012 at 3:13 PM

Looks like you did it! Case closed.