views:

204

answers:

1

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 UserID)
  • All Users in a specific group (by GroupID)
+1  A: 

Here is a good reference from MS

http://msdn.microsoft.com/en-us/library/d6s958d6%28VS.71%29.aspx

Charlie Brown
Awesome link! Thanks! Looks like what I need to do is create DataTables for the three tables I mention, and create DataRelations between Users and UsersInGroups and UsersInGroups and Groups. Then to get all groups with a certain user, I use user.GetChildRows("Users_To_UsersInGroups"), and for each child row (in UsersInGroups) run userInGroup.GetParentRow("Groups_To_UsersInGroups") to get the Group info.
Toby