Solved

How to make LINQ use column default values?

Posted on 2009-07-11
1
297 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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

10 Experts available now in Live!

Get 1:1 Help Now