Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. lost precision when pulling decimal

lost precision when pulling decimal

Scheduled Pinned Locked Moved LINQ
databasehelpcsharpsql-servervisual-studio
4 Posts 3 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bwilhite
    wrote on last edited by
    #1

    I'm quite new to both DBMSs and Linq... I've looked numerous places for the answer, which I'm sure is quite elementary. However, I'm sure my lack of full understanding is probably why I can't find the answer either. So any help is greatly appreciated. I'm working with VS '08 express and SQL Server Express. I have a table called 'Quotes' that has a column called 'Bid' in it that is type decimal(18,8). I used the Object Relational Designer to create an entity class called 'Quote.' I am then querying the table with these two lines: DataClasses1DataContext db = new DataClasses1DataContext(); Quote q = db.Quotes.SingleOrDefault(m => m.Id == someId); The problem that I'm having is that when I go to use q.Bid, the value has been rounded to the nearest integer. This is obviously not desirable. Brandon W.

    P N B 3 Replies Last reply
    0
    • B bwilhite

      I'm quite new to both DBMSs and Linq... I've looked numerous places for the answer, which I'm sure is quite elementary. However, I'm sure my lack of full understanding is probably why I can't find the answer either. So any help is greatly appreciated. I'm working with VS '08 express and SQL Server Express. I have a table called 'Quotes' that has a column called 'Bid' in it that is type decimal(18,8). I used the Object Relational Designer to create an entity class called 'Quote.' I am then querying the table with these two lines: DataClasses1DataContext db = new DataClasses1DataContext(); Quote q = db.Quotes.SingleOrDefault(m => m.Id == someId); The problem that I'm having is that when I go to use q.Bid, the value has been rounded to the nearest integer. This is obviously not desirable. Brandon W.

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      In your LINQ to SQL designer, what data type has been assigned to the 'Bid' field?

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      1 Reply Last reply
      0
      • B bwilhite

        I'm quite new to both DBMSs and Linq... I've looked numerous places for the answer, which I'm sure is quite elementary. However, I'm sure my lack of full understanding is probably why I can't find the answer either. So any help is greatly appreciated. I'm working with VS '08 express and SQL Server Express. I have a table called 'Quotes' that has a column called 'Bid' in it that is type decimal(18,8). I used the Object Relational Designer to create an entity class called 'Quote.' I am then querying the table with these two lines: DataClasses1DataContext db = new DataClasses1DataContext(); Quote q = db.Quotes.SingleOrDefault(m => m.Id == someId); The problem that I'm having is that when I go to use q.Bid, the value has been rounded to the nearest integer. This is obviously not desirable. Brandon W.

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        Sorry, but I did a quick test and can't confirm this behavior. I have decimal columns that are being returned fine. Check the datatype of the column attribute in the generated class for the Bid property.


        only two letters away from being an asset

        1 Reply Last reply
        0
        • B bwilhite

          I'm quite new to both DBMSs and Linq... I've looked numerous places for the answer, which I'm sure is quite elementary. However, I'm sure my lack of full understanding is probably why I can't find the answer either. So any help is greatly appreciated. I'm working with VS '08 express and SQL Server Express. I have a table called 'Quotes' that has a column called 'Bid' in it that is type decimal(18,8). I used the Object Relational Designer to create an entity class called 'Quote.' I am then querying the table with these two lines: DataClasses1DataContext db = new DataClasses1DataContext(); Quote q = db.Quotes.SingleOrDefault(m => m.Id == someId); The problem that I'm having is that when I go to use q.Bid, the value has been rounded to the nearest integer. This is obviously not desirable. Brandon W.

          B Offline
          B Offline
          bwilhite
          wrote on last edited by
          #4

          The type is showing up as decimal in the data designer. Strangely, it now seems to be working, without any real intervention on my part. The only thing I did, was to try changing the Bid type to Numeric (still didn't work) and then back to Decimal (now working). The only thing I can figure is that somehow it was wrong in the designer, but by going through my changes I managed to get it to change to the correct type...? This is in spite of the fact that I'm fairly certain that from the start I had the type as decimal in my table. I'll be designing some more tables, so I'll try to be sure to pay very close attention to what I'm doing, in case it happens again. BW

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups