There are several ways to deal with this situation:
You can make the DTO Enum property a string (since everything can successfully deserialize to a string :), and then manually convert it manually.
using ServiceStack.Common;
Another option is to completely remove it from the DTO request and get the value manually from the IHttpRequest context, for example:
public class RequestDto {} public override object OnGet(RequestDto request) { MyEnum enumValue = MyEnum.DefaultValue; try { var enumStr = base.RequestContext.Get<IHttpRequest>().QueryString["EnumString"]; enumValue = enumStr.ToEnum<MyEnum>(); } catch {} }
I generally do not recommend using DTO enumerations for many reasons, the main one being XML / SOAP endpoints, XSD treats them as a limited set of values, which is a pain when trying to iteratively develop your web services, since you need to reuse clients add new value.
By convention, as I do this, you need to have all the enumerations as strings, but provide some metadata in the DTO that indicates the target type (which helps in the navigation and metadata tools of VS.NET/R#).
public class RequestDto { [References(typeof(MyEnum))] public string EnumString { get; set; } }
source share