BinaryFormatter in ADO.NET 2.0
This is hardly hot off of the press, but I had a few questions about it and figured I'd post it. There is a new RemotingFormat property w/ DataSets in ADO.NET 2.0 - and depending on how you are trying to work things, the differences can be profound. Note that when I use 10 records, the XML version is 1kb whereas the Binary is 7kb - but my how quickly seasons change.....
SqlConnection cn = new SqlConnection("Server=PimpDaddyServer;Integrated Security=True;Database=AThaWayThug");
SqlCommand cmd = new SqlCommand("SELECT PimpID, PimpName FROM Thugs WHERE PimpID < 1000", cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet("Pimpin");
da.Fill(ds,
"AintEasy");
ds.WriteXml(
@"C:\sizetest.xml"); //94kb @1,000 - 955kb @10,000
ds.RemotingFormat =
SerializationFormat.Binary;
IFormatter Formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
Stream myStream = new FileStream(@"C:\sizetest.bin", FileMode.Create);
Formatter.Serialize(myStream, ds);
//24kb @1,000 - 196kb @10,000