Hi, I'm using Linq to SQL to write several unit tests. Sometimes I have code something like this:
var products = dataContext.Products;
Assert.That(1, dataContext.ExecuteQuery<int>("select count(*) from product").First()); //this works
Assert.That(1, products.Count()); //this works
dataContext.spCalculateMoreProducts();
Assert.That(2, dataContext.ExecuteQuery<int>("select count(*) from product").First()); //this works
Assert.That(2, products.Count()); // this fails, saying that got 1 instead of 2
spCalculateMoreProducts is a stored procedure that inserts more products outside Linq to SQL. The problem with this is that dataContext.Products is never refreshed. My understanding is that this is how Linq to SQL works. I think it's fine in general, but I would like to somehow force a refresh so I can write my unit tests like above. I can't create a new datacontext, because the whole unit tests runs in a single transaction, which is rolled back at the end. Any ideas?
Thanks