我有一个非常简单的 Request DTO,只要我填充除List<int>
. 我也尝试了一个数组,我得到了同样的错误:
错误代码:
'((ServiceStack.ServiceClient.Web.WebServiceException)($exception)).ErrorCode' threw an exception of type 'System.IndexOutOfRangeException'
错误信息:
'((ServiceStack.ServiceClient.Web.WebServiceException)($exception)).ErrorMessage' threw an exception of type 'System.IndexOutOfRangeException'
响应体:
"ResponseStatus":{
"ErrorCode":"SerializationException",
"Message":"KeyValueDataContractDeserializer: Error converting to type: Input string was not in a correct format.",
"StackTrace":" at ServiceStack.ServiceModel.Serialization.StringMapTypeDeserializer.PopulateFromMap(Object instance, IDictionary`2 keyValuePairs) in C:\\src\\ServiceStack\\src\\ServiceStack.Common\\ServiceModel\\Serialization\\StringMapTypeDeserializer.cs:line 108
at ServiceStack.ServiceHost.RestPath.CreateRequest(String pathInfo, Dictionary`2 queryStringAndFormData, Object fromInstance) in C:\\src\\ServiceStack\\src\\ServiceStack\\ServiceHost\\RestPath.cs:line 331
at ServiceStack.WebHost.Endpoints.RestHandler.GetRequest(IHttpRequest httpReq, IRestPath restPath) in C:\\src\\ServiceStack\\src\\ServiceStack\\WebHost.Endpoints\\RestHandler.cs:line 106
at ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) in C:\\src\\ServiceStack\\src\\ServiceStack\\WebHost.Endpoints\\RestHandler.cs:line 62"
}
我不知道该怎么办。它是导致崩溃的简单整数列表。如果我将属性留空并使用 DTO 上的任何其他字符串或整数,它就可以正常工作。我知道 ServiceStack 应该能够处理这个问题。我是 ServiceStack 的 v 3.9。
这是(非常简短的)代码:
//DTO
Route("/employee")]
public class EmployeeSearch: IReturn<List<Employee>>
{
public string FirstNameEquals { get; set; }
public string LastNameEquals { get; set; }
...
public int[] InDepartment { get; set; }
}
...
//Request
//SearchCriteria is of the above type
result.Employees = _client.Get(result.SearchCriteria);