Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to make LINQ use column default values?

Posted on 2009-07-11
1
Medium Priority
?
334 Views
Last Modified: 2013-11-11
I have a table with four columns.  One column is a datetime, which uses the SQL Server function getdate() for the column's default value.  When I drop this table onto my DBML in .NET, all four columns appear.  

I never explicitly supply a value for the datetime column on inserts in .NET (C#) since I want to use the default provided from above in SQL Server.  I have to delete the datetime column from the DBML since it breaks inserts.  I get the SQL error that my date is out of range, since .NET, I assume, is trying to supply a datetime value for that column, rather than letting SQL Server do it.  

The datetime column is needed for LINQ selects but not inserts.  So, I do need the datetime column in the DBML for selects.  How can I get around this issue so that the SQL Server default value is used on inserts, yet I can access the column for selects?  Others entities, such as an SQL Server job may insert into this table.  So the default of getdate() is necessary.
0
Comment
Question by:brettr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
jinal earned 2000 total points
ID: 24830978
Hello ,

Just do one thing . open dbmp file  then click on date column and select auto generated value to true.

Please look at attached image.

linq-date-setting.JPG
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question