For a project, I need to store an entity (and all entities that are assigned as properties) in a single file.

I figured I could just store it in a sqlserverce db file, but I'm unable to find a way to 'copy' an object that I fetched from our 'real' sql server connection to the sql server ce db file, without copying the properties manually, recreating the child entities where needed.

Is there really no easier way to store an entity to a single file?

I need to store the entity, so I can transfer it over the internet.

asked May 03 '11 at 04:32

TimM's gravatar image


3 Answers:

You can create DTO objects and use O2O mapping feature of DataObjects to "copy" content of "real" entities to DTO entities. You must write simple DTO classes with all properties as "real" do class and write O2O mapping builder to map "real" classes with DTO classes. Or you can wait for new version of DataObjects.Net Entity Model Designer (version which will contain new feature to generate DTO classes from model also with generated "mapping builder" class. Then you can serialize those DTO classes with standard BinaryFormatter

answered May 03 '11 at 04:50

Peter%20%C5%A0ulek's gravatar image

Peter Ĺ ulek


you could additionally take a look at WCF Data Services sample which is included into DataObjects.Net installer.

answered May 03 '11 at 04:53

Dmitri%20Maximov's gravatar image

Dmitri Maximov

I have created extension methods to 'clone' one (or more entities) from a domain to another domain (using reflection).

In my case I can now copy entities from/to our sql server express / sql server ce databases and am now able to export one or more entities to a container (a sql server ce file). Both 'domains' were build using the same DomainConfiguration.

This is a sufficient solution for now, but would be nice to see 'core' support for copying entities cross-domain if they are built using the same configuration.

answered May 13 '11 at 05:37

TimM's gravatar image


Hello TimM,

This is more like 'Sync' feature but what would you do if there is a conflict between entities? Say you have 2 domains and in both of them an entity has changed. You serialize this entity from the first domain. Will your clone procedure override the state of the entity from the second domain or not?

(May 13 '11 at 06:11) Dmitri Maximov Dmitri%20Maximov's gravatar image

No, these extensions purely copy the entities from domain A to domain B and will always create new entities. It will correctly reference the created child-entities to the correct fields.

For my needs this is sufficient, as I just needed a way to copy entities to/from a single file.

(May 13 '11 at 06:21) TimM TimM's gravatar image

OK, I see that there is no need in entity conflict management in your case. That's greatly simplifies the logic of the entire import process.

On the other hand, if we are to add 'Sync' feature to the core functionality we have to add all this stuff with versions/conflicts/merge behavior, etc., so the solution to be usable in wide variety of cases.

(May 13 '11 at 06:32) Dmitri Maximov Dmitri%20Maximov's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview


Once you sign in you will be able to subscribe for any updates here



Asked: May 03 '11 at 04:32

Seen: 2,725 times

Last updated: May 13 '11 at 06:32

powered by OSQA