Search code examples
wcfreflection.emitwcf-data-serviceslinqpad

How does LinqPad support WCF Data Services?


LinqPad supports WCF Data Services. If you assign an URL, such as http://services.odata.org/Northwind/Northwind.svc/. It will list all available data objects and you can query them. I guess LinqPad generates all available data classes at run time by reflection.Emit.

I am wondering who can show me to how to do so. Or maybe someone has done it before.

Any feedback are appreciated.

Ying


Solution

  • This is what I've got after examining the code with Reflector:

    LinqPad uses the built-in EntityClassGenerator class to generate code and then compile it with CSharpCodeProvider. No reflection emit is used. (It does use reflection emit to generate code in the case of LINQ-2-SQL though.)

    As to the ODataExplorer tool suggested by Vitek, it doesn't seem to generate code at all. It doesn't need to, because all interactions between it and the service are done through the REST API, not LINQ. So no strongly typed data context is needed.