ADO.NET DataRelations and many-to-many relationship
I was really drawn in and fascinated by the DataRelation object for use in an ADO.NET DataSet to cache data from my database in an ASP.NET web application. Unfortunately, I realized quite late, that I really have three DataTables.
- Users with a PK of UserID
- Groups with a PK of GroupID
- UsersInGroups a linking table with UserID and GroupID columns
Is it possible to load these three tables into a DataSet, add DataRelations, and then retrieve:
- All Groups
- All Users
- All Groups that contain a certain user (by Use开发者_JAVA技巧rID)
- All Users in a specific group (by GroupID)
Here is a good reference from MS
http://msdn.microsoft.com/en-us/library/d6s958d6(VS.71).aspx
精彩评论