Loop through table of datacontext
What I would like to do is, loop through a datacontext and for each table
found, select two different rows and compare the individual columns and
see if the rows are equal.
So far I've made a method to compare the values of two rows and return
true if all values of the rows are equal.
Now I would like to put this method into a foreach loop along the lines
outline below:
using (DataClassesDataContext db = new
DataClassesDataContext(Utillities.dbconnection))
{
foreach (Table t in db)
{
var row1 = from r1 in t where r1.id == constraint1 select;
var row2 = from r2 in t where r2.id == constraint2 select;
bool compResult = CompareRows(row1, row2);
}
}
But I don't know how to construct the foreach loop, so I can make the
above selections :( I've tried db.Mapping.GetTables(), but I can't see how
this gets me closer - I can only get the table-names in the datacontext,
not the tables themselves. Are there a way to get a table entity from a
string containing the tablename? Or am I missing something (likely
something obvious)?
Any help or hints with the above foreach loop will be much appreciated.
No comments:
Post a Comment