Database Reference
In-Depth Information
Following is the output of the code in Listing 13-28:
2 proxies generated!
Album: Abbey Road
Come Together by The Beatles
Album: Cowboy Town
Cowgirls Don't Cry by Brooks & Dunn
Album: Long Black Train
In My Dreams by Josh Turner
Jacksonville by Josh Turner
How It Works
Dynamic proxies are created just before they are needed at runtime. This, of course, means that the overhead of
creating the proxy is incurred on the first query. This lazy creation approach works well in most cases. However,
you can generate the proxies before the entities are first loaded by calling the CreateProxyTypes() method.
The CreateProxyTypes() method takes an array of types and generates the corresponding tracking proxies. Once
created, the proxies remain in the AppDomain for the life of the AppDomain. Notice that the lifetime of the proxy is
tied to the AppDomain, not the object context. We could dispose of the object context and create another, and the
proxies would not be disposed. You can retrieve the proxies in the AppDomain with the GetKnownProxyTypes() static
method on the object context.
 
Search WWH ::




Custom Search