Duplicate LINQ to SQL entity / record?

前端 未结 5 1008
傲寒
傲寒 2021-01-02 02:35

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 mak

5条回答
  •  忘掉有多难
    2021-01-02 02:41

    In Entity framework 6 you can do this

    Dim WorkoutNew As New Workout 'create a record
    ff7db.Workouts.Add(WorkoutNew) 'add it to the table (workout)
    ff7db.Entry(WorkoutNew).CurrentValues.SetValues(WorkoutsPost) ' update its values with a class with the same properties
    

提交回复
热议问题