locked
Return complex types RRS feed

  • Question

  • I have read that data services can return complex types from services operations. My data service is based on an entity model. When I do the following I get an error saying the data service can only return entities or primitives types.


     <WebGet()> _
        Public Function GetTest() As IQueryable(Of TestObject)
            Dim lst As New List(Of TestObject)
            Dim obj1 As New TestObject
            obj1.TestID = 1
            lst.Add(obj1)
            Return lst.AsQueryable
        End Function




    Public Class TestObject

        Private _TestID As Integer
        Public Property TestID() As Integer
            Get
                Return _TestID
            End Get
            Set(ByVal value As Integer)
                _TestID = value
            End Set
        End Property



    End Class

    Tuesday, January 27, 2009 1:57 PM

All replies

  • No no we dont tell you the answer, you have to pay for this kind of support
    --------------joking aside


    Hi Fresno Bob

    The return of complex types is only allowed when the complex type in question is owned by the data source used by the DataService<T> object.

    Now opening the flood gates of the official answers: We are currently aware of that limitation and we will be looking at that when the time comes.

    Basically cross your fingers, hopefully it will be on the next release of Astoria ... opps.. ADO.Net Data Services.

    Daniel Portella Blogger from hell http://undocnet.blogspot.com
    ---------------------------
    Daniel Portella - http://undocnet.blogspot.com - This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, January 27, 2009 2:38 PM
  •  Could you explain what "complex type in question is owned by the data source used by the DataService<T> object" means. Any code snippets would be great. At the moment I am creating views and selecting stored procs into them for things which don't map to entities. Also how complex is complex?
    Tuesday, January 27, 2009 4:56 PM
  • No no we dont tell you the answer, you have to pay for this kind of support
    --------------joking aside


    Hi Fresno Bob

    Basically if you are using lets say Entity framework or the ling to sql toolkit would mean that if your complex type is not a table on either it will not work. It must be on your model. I could point you to the Url on msdn but I think you have already read that.

    See small example below.

    AdventureWorkEntities (object context model)

    Customers (table or entityset)
    Orders (table or entityset)

    That would mean you could only return Customer and Order types on service operations.

    You cant return complex types created by yourself. If it not on the object context model it can not be referenced.

    Daniel Portella Blogger from hell http://undocnet.blogspot.com

    Daniel Portella - http://undocnet.blogspot.com - This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Daniel Portella Wednesday, January 28, 2009 8:34 PM
    Wednesday, January 28, 2009 9:53 AM