Solved

How to make LINQ use column default values?

Posted on 2009-07-11
1
305 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
1 Comment
 
LVL 15

Accepted Solution

by:
jinal earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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