Gets the
ObjectContextFactory that allows creating
ObjectContext instances by applying a
policy.
Such as creating a new
ObjectContext instance on each call (ASP.NET applications) or for
each different thread (Windows applications).
Syntax
Example
This example shows how to set up the factory to create an ObjectContext instance for each new thread.
| C# | Copy Code |
|---|
// Set the policy for multi threading. ObjectContext.Factory.Policy = new PerThreadObjectContextFactoryPolicy(delegate() { MsSqlStorage storage = new MsSqlStorage("... connection string ..."); ObjectContext ctx = new ObjectContext(storage); return ctx; }); // ... Other code // Have an ObjectContext instance created ObjectContext context = ObjectContext.Factory.GetObjectContext(); |
Requirements
Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family
See Also