views:

147

answers:

1

I have a simple little data model resembling the following:

InventoryContext {

IEnumerable<Computer> GetComputers()

IEnumerable<Printer> GetPrinters()

}

Computer {

public string ComputerName { get; set; }

public string Location { get; set; } }

Printer {

public string PrinterName { get; set; }

public string Location { get; set; }

}

The results come from a non-SQL source, so this data does not come from Entity Framework connected up to a database.

Now I want to expose the data through a WCF OData service. The only way I've found to do that thus far is creating my own Data Service Query Provider, per this blog tutorial:

http://blogs.msdn.com/alexj/archive/2010/01/04/creating-a-data-service-provider-part-1-intro.aspx

... which is great, but seems like a pretty involved undertaking. The code for the provider would be 4 times longer than my whole data model to generate all of the resource sets and property definitions.

Is there something like a generic provider in between Entity Framework and writing your own data source from zero? Maybe some way to build an object data source or something, so that the magical WCF unicorns can pick up my data and ride off into the sunset without having to explicitly code the provider?

+1  A: 

You can use so called "reflection provider". This assumes that you have a property (or many properties) which returns IQueryable (T being your entity type). Take a look at this video for a simple "How to" to get you started. http://msdn.microsoft.com/en-us/data/cc745968.aspx

Vitek Karas MSFT