Duplicate database entry using linq

Is there a way to duplicate a db entry from 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 the record (but give it a different identifier), so that new fields added to the database and the Linq dbml file later will be duplicated to change this code, which duplicates the record.

those. I do not want to write newRecord.Foo = currentRecord.Foo;for all fields in the table.

+5
source share
1 answer

I'm not sure if this is what you want, but the next stream includes the code using reflection and the extension method in the DataContext so that you can easily copy elements from one object to another.

Duplicate LINQ to SQL entity / record?

+1

All Articles