Kirk Marple

Musings of a Yukon and Whidbey pioneer... and feeling the arrows in my back...

<July 2008>
SuMoTuWeThFrSa
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789


Navigation

Subscriptions

Post Categories



Friday, January 07, 2005 - Posts

DbParameter.CopyTo now obsolete... Reflector to the rescue
I'd been using DbParameter.CopyTo method for cloning DbParameters, but then found with the Nov CTP that it's going away (marked obsolete).

Unfortunately, MSFT failed to provide any documentation as to what to use instead. I've posted newsgroup msgs and filed a Product Feedback Center question about it, but got no response.

Since i was getting back to my .NET 2.0 project today, i pulled out Lutz Roeder's .NET Reflector to try and solve this. Man, this is the *best* free tool out there. It's just indispensible for figuring out the intricacies of the Frameworks, especially where there's no documentation available.

It's interesting because it basically converts the Frameworks into an "exposed source" library, like MFC used to be.

Here's what CopyTo looks like:

[Obsolete("Do not use, will be removed post pd9.")]
public override void CopyTo(DbParameter destination)
{      

ADP.CheckArgumentNull(destination, "destination");      
this.CloneHelper((SqlParameter) destination);
}

But if it's going away, I needed a replacement. So, I noticed that CopyTo was calling CloneHelper, and also saw that .ctor(SqlParameter) called CloneHelper. But it also called ICloneable.Clone. It hit me that using ICloneable.Clone is probably the "preferred" approach (since CloneHelper is private). I tried replacing CopyTo with that, and it looks like it's working so far.

posted Friday, January 07, 2005 11:02 AM by kmarple with 4 Comments




Powered by Dot Net Junkies, by Telligent Systems