是ServiceStack中需要的“a Request DTO”的无参数构造函数
如果我注释掉无参数的构造函数
[DataContract]
[RestService("/Competitions/", "GET")]
[RestService("/Competitions/{Id}", "GET")]
public class Competitions
{
[DataMember]
public int CompetitionID { get; set; }
[DataMember]
public string CompName { get; set; }
[DataMember]
public string CompType { get; set; }
//public Competitions()
//{
//}
public Competitions(ABC abc)
{
this.CompetitionID = abc.abcID;
this.CompName = abc.CompName;
this.CompType = abc.CompType;
}
}
访问元数据页面http://localhost/api/xml/metadata?op=Competitions时会出现异常“No parameterless constructor servicestack”
堆栈跟踪是
[External Code]
ServiceStack.DLL!ServiceStack.WebHost.Endpoints.Metadata.XmlMetadataHandler.CreateMessage(System.Type dtoType = {Name = "Competitions" FullName = "FSI.API.ServiceModel.Competitions"}) Line 17 + 0x8 bytes C#
ServiceStack.DLL!ServiceStack.WebHost.Endpoints.Metadata.BaseMetadataHandler.ProcessOperations(System.Web.UI.HtmlTextWriter writer = {System.Web.UI.HtmlTextWriter}, ServiceStack.ServiceHost.IHttpRequest httpReq = {ServiceStack.WebHost.Endpoints.Extensions.HttpRequestWrapper}) Line 56 + 0xe bytes C#
ServiceStack.DLL!ServiceStack.WebHost.Endpoints.Metadata.BaseMetadataHandler.Execute(System.Web.HttpContext context = {System.Web.HttpContext}) Line 34 C#
ServiceStack.DLL!ServiceStack.WebHost.Endpoints.Support.HttpHandlerBase.ProcessRequest(System.Web.HttpContext context = {System.Web.HttpContext}) Line 20 C#
[External Code]