Duplicate LINQ to SQL entity / record?

Posted by GONeale on Stack Overflow See other posts from Stack Overflow or by GONeale
Published on 2009-03-12T06:04:01Z Indexed on 2010/06/08 10:22 UTC
Read the original article Hit count: 232

Filed under:
|

Hi guys,

What would be considered the best practice in duplicating [cloning] a LINQ to SQL entity resulting in a new record in the database?

The context is that I wish to make a duplicate function for records in a grid of an admin. website and after trying a few things and the obvious, read data, alter ID=0, change name, submitChanges(), and hitting an exception, lol. I thought I might stop and ask an expert.

I wish to start with first reading the record, altering the name by prefixing with "Copy Of " and then saving as a new record.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about linq-to-sql