Search code examples
.netwcfwcf-data-services

WCF Data Service Run Time EDMX


What I am looking may not be readily available. If so please let me know.

Have an application where a users in a role can dynamically add fields. Fields are used to classify documents.

For string just have a single (static schema) table with pk as rowID, fieldID and a non-key field of value. For example fieldID = 1 is Subject and fieldID = 2 is Author. So can add user fields with no change to the database schema. Subject = Mapping maps to TSQL (fieldID=1 and Value='Mapping')

The primary interface is a UI but also have a button to export the search results (rows of fields) to XML. It is popular and would like to extend that to on ODATA type access.

Would like to add a WCF Data Service but expose the entity with properties Subject and Author and .... Read about EntityObject Generator but it appears need to update the reference. What I need is the EDMX to be built and read at run time and then a facility to map Subject="Mapping" to (fieldID=1 and value="Mapping").

Hopefully I have described what I am looking for. Not looking for a prescriptive type answer. More like this tool should get you there or a no it just does not work that way.

I don't know much about ODATA or WCF Data Service but if it looks like there is a way to make this work I will learn it .

Thanks


Solution

  • Since it seems the requirement is to generate entities with dynamic properties based on the fields rows in the DB, this can't be done using the built-in EF or Reflection providers (since both rely on having statically defined CLR types to define the entities).

    The way to solve this is to implement a custom provider as described in this blog series: http://blogs.msdn.com/b/alexj/archive/2010/01/07/data-service-providers-getting-started.aspx Namely the un-typed custom provider.