views:

108

answers:

2

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

A: 

I'm pretty sure that LinqPad generates the classes as you suggested, but I haven't seen to source code. But if you're interested in source code for something similar, take a look at OData explorer: http://blogs.msdn.com/b/phaniraj/archive/2010/03/17/announcing-the-odata-explorer.aspx

Vitek Karas MSFT
+2  A: 

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.

Buu Nguyen