开发者

Handling a Linq-To-Sql mapping to a table colum with a default value/binding

开发者 https://www.devze.com 2022-12-15 02:19 出处:网络
I have a Linq-To-SQL mapping to 开发者_JAVA技巧a column in a SQL table. This column is type DateTime with default mapping / binding of getdate().

I have a Linq-To-SQL mapping to 开发者_JAVA技巧a column in a SQL table.

This column is type DateTime with default mapping / binding of getdate().

The problem is that Linq-To-SQL tries to insert 12/1/0001 12:00 AM instead of letting SQL do its thing and insert getdate().

Is there a way around this?

Additionally, if the column is allowed to be null, why does 'Linq-to-SQL' try to insert a default value?


This might help (scroll up a wee little bit). It talks of setting the IsDbGenerated and AutoSync properties, which tell the data context that the value is generated at the DB and how the value in the L2SQL object should be synced with the value in the database.

I think my google fu is low today, I'm positive I've read a good article/blog post about this, but I cannae find it again.

0

精彩评论

暂无评论...
验证码 换一张
取 消