This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello - I am still running Lightspeed 4 and VS 2010 - I plan on upgrading shortly but first I want to get to a better stopping point with the current project. That said, I am running into a bit of money trouble. No, not that kind, the "how do I compare these quantities" kind. :) In this snippet, what I am trying to do is use an existing Item ONLY IF it has the same item number and price as the one I am trying to save. If the price changes, I need to create a new Item as these values are used for reporting and are subject to change.
The problem is I don't have control over the precision of the incoming values. The original values come from an Oracle database with 6 decimal places of precision and I am storing them in a SQL database as Money data type, with 4 decimal places of precision. Since I don't really know what SQL Server does when it imports a decimal with 6 places of precision into a Money data type, I want to convert both values into something that I have control over. I really only need to compare to a precision of 2, so I tried the following:
Lightspeed does NOT like the Math.Round() calls embedded in the Linq query! Any ideas on how I could do this? To reiterate, what I want to do is ensure I have the exact same decimal values when I compare the Price values so I don't get unnecessary multiple entries. Thanks, Dave |
|
|
Yes, you can add a custom mapping to cater for Math.Round by specifying a custom mapping. The how is described in this blog post from Ivan - http://www.mindscapehq.com/blog/index.php/2009/08/10/custom-functions-in-linq/ Let me know if you have any issues with this :)
|
|