Say i have the following table:
create table T (
ID int not null primary key,
Name varchar(10) not null,
CreatedAt datetime not null default GETDATE(),
UpdatedAt datetime not null default GETDATE()
)
and want to use with Linq 2 Sql. It perfectly generates type safe class with both CreatedAt and UpdatedAt properties non-nullable. Now i want to insert a new entry and want them both to be populated by a value from Sql Server, not with DateTime.Now
which may differ. Is there a way to somehow send null
to Sql Server without making the properties nullable? Also, i don't want to follow this solution as it requires additional network trip. It's very easy with good old SQL - just omit CreatedAt/UpdatedAt columns in the insert statement and you're fine but what are my options with Linq 2 Sql?