Search code examples
c#entity-frameworkodatadataservice

How to add a programmatically created entity to a Data Service?


Currently, I am able to create entities in my Data Service that are mapped to existing tables and views in a given SQL Database. The issue is that I do not want those very complex views to reside in the database. Is there any way to embed them into the Data Service or populate those entities programmatically?

As of now, I believe I have to use partial classes and create the entities on initialization.

I have searched and have not been able to find a solution. Any help will be greatly appreciated! Thanks.


Solution

  • I was able to resolve this issue by using these resources:

    https://msdn.microsoft.com/en-us/data/jj730307.aspx

    https://social.msdn.microsoft.com/Forums/en-US/52b1bb00-5226-46d0-b2ee-92aac0e82c22/the-type-is-not-qualified-with-a-namespace-or-alias-only-primitivetypes-can-be-used-without?forum=adodotnetdataservices

    They show how to map entities to custom queries (residing on the dataservice) thus allowing me to eliminate the views from my clients' databases.