ExtendedObjectDataSource samples

Product Information


When the ObjectDataSource has to perform a Select operation it has to retrieve all methods of the type that will handle the operations, find a matching method in the list of methods of the type, and then invoke the method using reflection. For an Insert, Update or Delete operation if is using custom objects as parameters, it also has to create an object as the parameter to the method and set its properties using reflection. As you can imagine, this process is very slow.

The CompatObjectDataSource and the ExtendedObjectDataSource perform a lot better than the ObjectDataSource because it can cache the method choosen for the Select, Insert, Update and Delete operations, so the expensive search for the requested method is performed only the first time, and instead of using reflection to invoke the method, create objects and set its properties, it generates MSIL code dynamically to perform those tasks, obtaining a 2000% performance increase (20 times faster!) over the reflection calls.

For small sites or low traffic sites the performance improvement is not noticeable but for high traffic sites the performance improvement can help you to increase the number of request handled per second.

Performance Comparison

To dynamically generate MSIL the ReflectionEmit permission should be granted. Most shared hosting providers have that permission added to sites that run in medium trust, or can add it by request. This optimization can be disabled setting the property UseDynamicMSIL to "false" if the hosting provider doesn't want to change it.