Duplicate a database record with linq
Posted
by holz
on Stack Overflow
See other posts from Stack Overflow
or by holz
Published on 2010-03-21T23:12:41Z
Indexed on
2010/03/21
23:21 UTC
Read the original article
Hit count: 203
linq-to-sql
|c#
Is there a way to duplicate a db record with linq to sql in c#?
Id [int] IDENTITY(1,1) NOT NULL PRIMARY KEY,
[Foo] [nvarchar](255) NOT NULL,
[Bar] [numeric](28,12) NOT NULL,
...
Given the table above, I would like to duplicate a record (but give it a different id), in a way that new fields added to the DB and the Linq dbml file at a later date will still get duplicated with out having to change that code that duplicates the record.
ie I don't want to write newRecord.Foo = currentRecord.Foo;
for all of the fields on the table.
© Stack Overflow or respective owner