How to: Identify that a POCO Entity is a Proxy
This topic shows how to identify whether a POCO entity is a proxy. There are occasions when you would like to test whether your POCO object is actually a proxy. When you create a POCO entity by using the CreateObject method, if the POCO type does not meet the requirements described in Requirements for Creating POCO Proxies, a POCO entity will be created instead of a proxy object. For more information, see Working with POCO Entities.
The example in this topic uses the POCO classes that are defined in How to: Define POCO Entities and an AdventureWorks-based data model that is defined in How to: Customize Modeling and Mapping Files to Work with Custom Objects.
The following example uses the CreateObject method to create a proxy object. The example then verifies whether the object is a proxy object by comparing the POCO type to the generated proxy type. If the types are not the same, then it is a proxy. If it is a proxy object, it is at a minimum a lazy-loading proxy object. To determine if it is also a change-tracking proxy object, we can see if changes are being tracked.