none
How to stop linq to sql from making null to 0? RRS feed

  • Question

  • i am using stored procedures to update the database.  One issue i have is when i need to save numeric fields back to the database and when they are null, linq to sql sends 0 to the database, instead of null.  Any way to change that behavior?  i need it to be null otherwise i will have all kinds of errors.  i can in the sql code check for 0 but i prefer to just send null because thats what it is supposed to be.

    thanks in advance for any suggestion.

    Thursday, May 5, 2011 6:27 PM

Answers

  • Hi Olavo,

    thanks for the response again your reply did help but wasnt really the issue.  I have code that explicitly convert a null to a zero, so i needed to remove that code.

    Monday, May 9, 2011 5:03 PM

All replies

  • Hi

    when are you using your procedure, the numeric parameters do not appear with ? in front ?

    If you put NULL in these parameters, it's to save NULL in the table.


    Olavo Oliveira Neto
    http://olavooneto.wordpress.com
    Se for útil marque como resposta e faça um Developer feliz :)
    Thursday, May 5, 2011 7:23 PM
  • yeah, i think its my code that make the null 0, silly me.

    thanks for the response!!

    Thursday, May 5, 2011 10:25 PM
  • Sorry, I don't understand My solution works ? if yes you can mark it? if not you can tell what's happening ? thanks
    Olavo Oliveira Neto
    http://olavooneto.wordpress.com
    Se for útil marque como resposta e faça um Developer feliz :)
    Thursday, May 5, 2011 10:42 PM
  • View Map field type whether it is numeric?   in .dbml

    Best Regards,
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Friday, May 6, 2011 12:06 AM
  • Hi Olavo,

    thanks for the response again your reply did help but wasnt really the issue.  I have code that explicitly convert a null to a zero, so i needed to remove that code.

    Monday, May 9, 2011 5:03 PM
  • Hi Tim, any idea why i am not getting email notifications when someone responds to this thread, or any thread i have subscribed to?  I have the Alert me check box checked.

    Monday, May 9, 2011 5:04 PM
  • Hi,

    I am also facing the same problem. No alerts even after checking the text box for "alert me".

    Wednesday, May 11, 2011 5:28 AM
  • Hi kumal,

    I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions? 
     
    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

     

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 18, 2011 1:52 PM
    Moderator