OK, so I have an SQLS db that I want to query using some JOIN commands. I know how to do that, but here's the bit I don't quite know how to do yet:
How do I bind the results of said query to a single typed list so that changes to the list can be easily written to the database?
Reason I want to do this is that I'm using a control (Phillip Piper's ObjectListView's TreeListView) that binds itself to a list, so I need to get data from that control back into the DB in a sensible manner that ideally doesn't involve tons of boilerplate code.
The idea being that the user can play with the values in the Treelistview (which automatically updates the list, this bit works quite happily), then the user can h开发者_开发知识库it save and then something (a dataadapter I'm guessing? I'm new to C# and SQLS and still fuzzy on the whole binding thing) updates just the changed values in the relevant tables.
Sorry if this seems like basic stuff, but putting 'bind query results to a typed list' into google returns loads of stuff that's irrelevant, or stuff that I'm not advanced enough to understand yet. I think I need this in pure newbie layman's terms :P
It sounds like you're after an ORM. Entity Framework is Microsoft's main ORM offering, though Linq2Sql is great and easy to use. NHibernate is another option.
Use Linq to SQL Have a look at PLINQO, it will automate most of it for you www.plinqo.com
In the end I canned the joined DataTable idea and just read the data straight into a List of my objects with a DataReader. So this whole question is now pretty redundant for me. Hopefully someone else will find it useful.
精彩评论