Solved

How to make LINQ use column default values?

Posted on 2009-07-11
1
299 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now