Solved

How to make LINQ use column default values?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
API v SOA 8 62
parse string in c# 5 40
Error in Visual Project 10 46
Delete command SQLdatasource in asp.net, vb 2 15
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

737 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