DataContext Interview Questions and Answers


 

Interview Question in DataContext

How can I re-attach an entity to a new DataContext

 How can I re-attach an entity to a new DataContext?  When I try to do this I get an exception thrown.

How can I keep entities cached beyond the lifetime of a single DataCon

 How can I keep entities cached beyond the lifetime of a single DataContext?  I want to keep a collection of entities in a cache so that all subsequent requests can read from this cache instead of going back to the database each time.

Should I keep my DataContext in a static/global/shared variable?

Should I keep my DataContext in a static/global/shared variable?

Should I create a new DataContext in every business logic method?

 Should I create a new DataContext in every business logic method?

How do I get default values from the database when inserting new entit

 How do I get default values from the database when inserting new entities?