Hi:
I'm developing a desktop application using Linq to SQL. From what I've gathered, it's better to keep DataContext objects short-lived, but I'm running into the following puzzle:
My application has lots of lookup-type data that I'd like to cache on the client. The reason I want to cache it is because I don't want to have to look up the appropriate parent record for every child record I need to insert when I'm doing large ETL-type operations.
When I perform updates to the database, I need to relate my updated records to this lookup data. Now, with a single, global DataContext, that's easy: I just add the new child records to the relation collections of the lookup objects and hit SubmitChanges().
But if I'm creating new DataContexts from the ones that I originally fetched the data from, how can I best manage updating this related data? I can't use the cached data with my new DataContext because it came from a different one.
This is all pretty confusing - should I give up and learn the Entity Framework instead?
Thanks much in advance.