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.