问题描述
我已经读过数据服务可以从服务操作返回复杂类型。我的数据服务基于实体模型。当我执行以下操作时,我收到一条错误消息,指出数据服务只能返回实体或基元类型。结果,搜索结果< 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)
返回lst.AsQueryable
结束函数
公共类TestObject
私有_TestID作为整数
公共属性TestID()作为整数
返回_TestID
结束获取
(ByVal值为整数)
_TestID = value
结束集
>
End Class
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
推荐答案
这篇关于返回复杂类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!