Dear all,
I have an SQL server databse that I access through an EF and an ShareContext defined as follow :
public class SharedObjectContext
{
private readonly QuizzEntities context;
#region Singleton Pattern
// Static members are lazily initialized.
// .NET guarantees thread safety for static initialization.
private static readonly SharedObjectContext instance = new SharedObjectContext();
// Make the constructor private to hide it.
// This class adheres to the singleton pattern.
private SharedObjectContext()
{
// Create the ObjectContext.
context = new QuizzEntities();
}
// Return the single instance of the ClientSessionManager type.
public static SharedObjectContext Instance
{
get
{
return instance;
}
}
#endregion
public QuizzEntities Context
{
get
{
return context;
}
}
}
This context is used in a global application when data need to be access. So once the context is instanciate once, it will reamain alive.
Do you think it could cuase trouble ?
Or is it better to create the Entities context each time needed ?
regards
serge
Your knowledge is enhanced by that of others.