Ben Reichelt's Weblog

Sponsors

The Lounge

Wicked Cool Jobs

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Copying Entities in an OO Fashion

[Advertisement]

Comments

Dennis van der Stelt wrote re: Copying Entities in an OO Fashion
on Tue, Nov 1 2005 3:10 AM
I just learned this myself a few days ago, it's called a copy constructor. It's apparently something from C++, and in C# it doesn't exist.

Read more about it here:
http://msdn2.microsoft.com/en-us/library/ms173116.aspx

Summary:
While creating a new object, in its constructor, you pass in an object of the same type. The constructor will then copy the passed object into itself, making an exact copy.

No idea if C++ supports this by default, unfortunatly C# doesn't. But perhaps with some reflection, you can create this yourself.
Ben Reichelt wrote re: Copying Entities in an OO Fashion
on Tue, Nov 1 2005 9:24 AM
Thanks for the comment Dennis, that would be pretty convenient :) To support an object copy (as opposed to a database copy), we are going to use a binary serializer. We'll serialize the object, and the immediately deserialize it back to an object and then return it. This way its a brand new object (not another reference) and its an exact copy.
Christopher Steen wrote Link Listing - November 3, 2005
on Thu, Nov 3 2005 2:02 PM
ADO.NET Provider Model Fundamentals [Via: dhayden ]
Ajax's responseXML Error [Via: ]

Anticipated...
Devlicio.us