locked
How to Create custom entity and expose it as a service as [WebGet]?? RRS feed

  • Question

  • Hi Guys

    I wish someone can help to show me how to create custom entity object which can be exposed as a service [WebGet]

    For example I have entity(Table)  automatically created with ADO.Net Entity Dataobject Model called: Order. And i want to create new object called OrderNote which basically something like this:

    class OrderNote
    {

    public Order Order1{get;set}

    public string Note {get;set}

    }

    How can I exposed this OrderNote class in the Data Service under [WebGet]?

    Tried, but always give an error.

    Thanks for the help.

    Regards

    Bonabon

    Monday, April 5, 2010 8:58 AM

Answers

  • Hi Bonabon,

     Unfortunately, we dont support injecting custom entity types which dont exist in the EDM model.

     If the Entity type was a part of the model , you could have done this  without any issues.

    Can you try introducing the type into the model and then expose it using a Service Operation ?

     


    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Monday, April 5, 2010 5:12 PM
    Moderator

All replies

  • Hi Bonabon,

     Unfortunately, we dont support injecting custom entity types which dont exist in the EDM model.

     If the Entity type was a part of the model , you could have done this  without any issues.

    Can you try introducing the type into the model and then expose it using a Service Operation ?

     


    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Monday, April 5, 2010 5:12 PM
    Moderator
  • Hi Bonabon,

     Unfortunately, we dont support injecting custom entity types which dont exist in the EDM model.

     If the Entity type was a part of the model , you could have done this  without any issues.

    Can you try introducing the type into the model and then expose it using a Service Operation ?

     


    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Monday, April 5, 2010 5:12 PM
    Moderator
  • Hi Bonabon,

     Unfortunately, we dont support injecting custom entity types which dont exist in the EDM model.

     If the Entity type was a part of the model , you could have done this  without any issues.

    Can you try introducing the type into the model and then expose it using a Service Operation ?

     


    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Monday, April 5, 2010 5:12 PM
    Moderator
  • Hi mate, thanks for the clarification. I guess I still need to use linq to sql classes for this type of requirement.

    I am trying to create composite objects to minimize web service call to improve the performance .

     

    Cheers

    bonabon

    Tuesday, April 6, 2010 1:47 PM
  • Just to understand, what are you trying to accomplish in these composite objects? With $expand, $select and batch queries, you can optimize bunch of things. I am sure that these don't cover the full spectrum, but just curious to know what kinds of things you want to do in your composite objects.

    Thanks

    Pratik


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, April 6, 2010 6:47 PM
    Moderator
  • Just to understand, what are you trying to accomplish in these composite objects? With $expand, $select and batch queries, you can optimize bunch of things. I am sure that these don't cover the full spectrum, but just curious to know what kinds of things you want to do in your composite objects.

    Also, you are right - if you want this functionality, you will have to use reflection provider (linq to sql classes) or write your own custom provider over linq to sql.

    Thanks

    Pratik


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, April 6, 2010 6:47 PM
    Moderator