Help Regarding DATARELATIONSHIP
-
Please Friends Help me i have 4 tables 1. Master Book Table (MBookId,BookId,AuthorId,PubId) 2. Book Name ( BookId,BookName) 3. Author Name (AuthorId,AuthorName) 4. Publisher Name (PubId, PubName) DAL UI Layer DAL ---- Please suggest me how to achieve Datarelationship
DataRelation dr = new DataRelation("BookBookName",
ds.Tables["MBook"].Columns["BookId"],
ds.Tables["Book"].Columns["BookId"]);ds.Relations.Add(dr);
is this right ? and how to use this in UI to get data, insert,update, save.. etc i google a lot but didn't find the right solution for my purpose and is datarelation ship with dataset is better or NHIBERNATE if nhiberate is better then do ineed to start in from start i mean i have to create the tables and all that once.......... i have already created the datatable and DAL methods of Save Edit etc.... Please Help Thank you very much EveryOne..... (specially CODEPROJECT)
-
Please Friends Help me i have 4 tables 1. Master Book Table (MBookId,BookId,AuthorId,PubId) 2. Book Name ( BookId,BookName) 3. Author Name (AuthorId,AuthorName) 4. Publisher Name (PubId, PubName) DAL UI Layer DAL ---- Please suggest me how to achieve Datarelationship
DataRelation dr = new DataRelation("BookBookName",
ds.Tables["MBook"].Columns["BookId"],
ds.Tables["Book"].Columns["BookId"]);ds.Relations.Add(dr);
is this right ? and how to use this in UI to get data, insert,update, save.. etc i google a lot but didn't find the right solution for my purpose and is datarelation ship with dataset is better or NHIBERNATE if nhiberate is better then do ineed to start in from start i mean i have to create the tables and all that once.......... i have already created the datatable and DAL methods of Save Edit etc.... Please Help Thank you very much EveryOne..... (specially CODEPROJECT)
You need to do following.
DataRelation dr = new DataRelation("BookBookName",
ds.Tables["MBook"].Columns["BookId"],
ds.Tables["Book"].Columns["BookId"]);DataRelation dr1 = new DataRelation("BookAuthorName",
ds.Tables["MBook"].Columns["AuthorId"],
ds.Tables["AName"].Columns["AuthorId"]);and so on. So you have finally four datarelation object. Then add all relation object to dataset, like..
ds.Relations.Add(dr);
ds.Relations.Add(dr1);
ds.Relations.Add(dr2);You can do navigation as follows
foreach (DataRow MBookRow in customerOrders.Tables["NBook"].Rows)
{
Console.WriteLine(MBookRow["MBookId"].ToString());foreach (DataRow BNameRow in MBookRow.GetChildRows(dr1)) { Console.WriteLine(BNameRow\["BookId"\].ToString() + " " + BNameRow\["BookName"\].ToString()); }
}
Refer this[^] link for DataSet Vs NHibernate. HTH
Jinal Desai - LIVE Experience is mother of sage....