Suppose I have a DataContext
object and access two tables at the same time:
using( var context = new DataContext( connectionString ) ) {
foreach( firstTableEntry in context.GetTable<FirstTable>() ) {
switch( firstTableEntry.Type ) {
case RequiresSecondTableAccess:
{
var secondTable = context.GetTable<SecondTable>();
var items = secondTable.Where( item => item.Id = firstTableEntry.SecondId );
foreach( var item in items ) {
handleItem( item );
}
}
default:
// not accessing the second table
}
}
Note that I don't stop using the first query results while making queries to the other table and use the same DataContext
object all the time.
Is such usage legal? Should I expect any problems with this approach?