System.Data.FillLoadOption
System.Data.FillLoadOption is one of the cool new features of the ADO.NET 2.0 SqlDataAdapter. In the new framework, we have a lot more control over the inner workings of the DataAdapter and hopefully it will shed it's stereotype of being a “Black Box”. Below is the basic workings of it - nothing new here that you can't find in the documentation but I figured I'd mention it:
SqlDataAdapter da = new SqlDataAdapter();
//The current and original values will be set to the
//new query values
da.FillLoadOption = System.Data.LoadOption.OverwriteChanges;
//The new query values will overwrite the original values.
//However the current values for the row won't be changed.
da.FillLoadOption = System.Data.LoadOption.PreserveChanges;
//The new query values will overwrite the current values of the row
//However the original values won't be changed.
da.FillLoadOption = System.Data.LoadOption.Upsert;
I gotta give it to the ADO.NET 2.0 team for the name Upsert. Most of the framework oozes of the Consistency Police (which is a good thing - I"m not criticising that) and this looks like a name they came up with after Happy Hour on Friday. Anyway, right now you have very little control over your Fill. Ifyou have rows and you don't have a key, calling Fill again will result in x + 1 sets of the same data. If you have a key, the behavior is different. It will look to the keyed rows and overwrite the values with the new ones. However, depending on your needs, this can be inconvenient.
Anyway, one thing I've been working on that is going VERY Slow but moving - is rewriting the Data Access Application Block to accomodate the new features of the 2.0 Framework. There's a lot there though in terms of work even though the features aren't that dramatic in terms of size (however the functionality is very impressive). What I'm saying is that the new features typically provide quite a bit of bang for the buck. If you're interested in working on this - please let me know. I'll be setting up a workspace on GotDotNet and if you're interested, please let me know.