当我在对象中包含datetime属性并在wcf服务中返回它然后它给出错误状态12152.在我的对象中没有datetime属性它工作正常。日期时间属性内容是#1/22/2016 12:08:36 PM#。 如何使它与datetime属性一起使用?
wcf call
function populateEditAuditResultData(AuditID) {
CallWCFService('DataService.svc/GetAuditCase',
'{"AuditID": "' + AuditID + '"}',
function (result) { //success
},
function (jQXHR, textStatus, errorThrown) { //failure
}
);
}
wcf service
<OperationContract()> _
Public Function GetAuditCase(ByVal AuditID As Integer) As AuditCase
Return New AuditCase(AuditID)
End Function
构造
Public Sub New(ByVal AuditID As String)
Me.AuditID = AuditID
Me.GetData()
End Sub
Public Sub GetData()
Dim conn = New DatabaseConnection()
Dim params = New List(Of SqlParameter)
If AuditID <> Nothing Then params.Add(New SqlParameter("AuditID", Me.AuditID))
Dim table = conn.RunSprocQuery(ReferenceData.prc_GetAuditCaseDetails, params.ToArray())
If table.Rows.Count > 0 Then
ReadAuditCase(table.Rows(0), Me)
End If
End Sub
Private Shared Sub ReadAuditCase(ByVal row As DataRow, ByRef AudCase As AuditCase, Optional ByVal IncludeOptionalFields As Boolean = True)
AudCase.AuditID = CInt(row("AuditID"))
AudCase.AuditTypeID = CInt(row("AuditTypeID"))
AudCase.AllocationOn = Convert.ToDateTime(row("AllocationOn"))
End Sub
答案 0 :(得分:0)
通过将时区更改为UTC来解决问题。 或者,可以使用以下代码解决它。
AudCase.AllocationOn = Convert.ToDateTime(row("AllocationOn")).ToUniversalTime()
希望这有助于他人。