OpenAccess ORM version
|
2013.2.702.1
|
.NET version |
.NET Framework 4.0 |
Visual Studio version |
VS 2010 |
programming language |
C#, VB
|
browser support |
all browsers supported by RadControls
|
PROJECT DESCRIPTION
This project shows how to copy an object or an entire graph in the database.
To achieve this goal we should first detach an entity from the context using the CreateDetachedCopy method with the proper fetch strategy to detach the whole graph, serialize the graph, deserialize it and Add it to the context.
The project includes both the custom code generation templates which modifies the domain classes and add
[Serializable] and a sample Domain Model defined using the template. The changes in the code generation templates could be founded in the
OpenAccess GitHub repository -
openaccess-templates / DomainModel / Serializable Entities / Version1 /.
For further information how to customize code generation templates refer to this article:
http://documentation.telerik.com/openaccess-orm/developers-guide/code-generation/customizing-code-generation/openaccess-tasks-customise-code-generation-overview
1) The first step is to detach the category from the database with the proper fetch strategy.
2) The second step is to serialize and deserialize the detached entities. This step should be done to remove the persistence tracking functionality of OpenAccess from the entity so the objects will be marked as new.
In the samples the Domain Model class is extended with partial class and there is added two methods CreateDeepCopy<T> and they could be used as extension methods from the dbContext.
C#
VB
Prerequisites
The Northwind database