Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 未添加wcf服务datacontract last属性_C#_Asp.net_Winforms_Wcf_Wsdl - Fatal编程技术网

C# 未添加wcf服务datacontract last属性

C# 未添加wcf服务datacontract last属性,c#,asp.net,winforms,wcf,wsdl,C#,Asp.net,Winforms,Wcf,Wsdl,我正在使用枚举向模型中添加属性 public class ChildCareCentreEntryReservation : BasketItem, ILockableBasketItem { .... [DataMember] public ChildCareCentreEntryReservationStatusTypes ChildCareCentreEntryReservationStatusType { get; set; } } [DataContrac

我正在使用枚举向模型中添加属性

public class ChildCareCentreEntryReservation : BasketItem, ILockableBasketItem
{
      ....
    [DataMember]
    public ChildCareCentreEntryReservationStatusTypes ChildCareCentreEntryReservationStatusType { get; set; }
}

[DataContract(Namespace = Constants.Namespace)]
public enum ChildCareCentreEntryReservationStatusTypes
{
    [EnumMember]
    VoorlopigIngeschreven = 0,
    [EnumMember]
    DefinitiefIngeschreven = 1,
    [EnumMember]
    Geannuleerd = 2
}
在我的表单中,我创建了一个ChildCareCentreEntryReservation对象:

  var reservation = new ChildCareCentreEntryReservation();
  reservation.ChildCareEntryPeriodId = _entryPeriod.Id;
  reservation.ChildCareCentreId = _centre.Id;
  reservation.PersonId = _person.Id;
  reservation.Comment = txtComment.Text;
  reservation.ChildCareCentreEntryReservationStatusType = (ChildCareCentreEntryReservationStatusTypes)cboStatusName.SelectedIndex;
我将ChildCareCentreEntryReservation对象添加到列表中:

var basketItems = new List<BasketItem> { reservation };
所有内容都正常构建和工作,但我的服务没有收到我最后添加的属性

Fiddler检查员结果(客户服务请求):


已解决

我必须将ChildCareCentreEntryReservationStatusTypeSpecified设置为true

 reservation.ChildCareCentreEntryReservationStatusTypeSpecified = true;
reservation.ChildCareCentreEntryReservationStatusTypeSpecified = true;

您在哪里创建ChildCareCentreEntryReservation对象?您要设置ChildCareCentreEntryReservation.ChildCareCentreEntryReservationStatusTypes属性的值是多少?您好,我刚刚用一些额外的信息更新了我的问题。我正在使用一个组合框来选择一个值,并使用所选的索引来定义选择枚举数的位置。(如果我从组合框中选择值2或值1,客户端不会向服务发送枚举数)我必须添加一个设置为true的额外属性:reservation.ChildCareCentreEntryReservationStatusTypeSpecified=true;请将此添加为答案,然后将其作为解决方案停放。这将帮助其他有类似问题的人。谢谢
  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
  <ActivityId CorrelationId="d1daee11-20e2-4e98-8774-9bffe4e2e4f3" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">728e68a9-17ff-44a0-b4ad-f455f403be5e</ActivityId>
    </s:Header>
    <s:Body>
      <LockBasketResult xmlns="http://www./" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <BasketItems>
    <BasketItem i:type="ChildCareCentreEntryReservation">
      <DivisionId>00000000-0000-0000-0000-000000000000</DivisionId>
      <Id>00000000-0000-0000-0000-000000000000</Id>
      <Quantity>1</Quantity>
      <RuleNamesToIgnore xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
      <UnitPrice>0</UnitPrice>
      <ChildCareEntryPeriodId>13ccefb3-f1e4-4f64-8fb8-b07cf30d2fca</ChildCareEntryPeriodId>
      <ChildCareCentreId>8cc85f37-da5d-46c5-9bb4-d6efa8448176</ChildCareCentreId>
      <PersonId>56e341bb-ac05-40dc-a39a-082ae4ff087e</PersonId>
      <ChildCareCentrePeriodIds xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <a:guid>61c43967-8781-4d83-a117-963c5734491f</a:guid>
      </ChildCareCentrePeriodIds>
      <LockTicket i:type="ChildCareCentreEntryReservationLockTicket">
        <ExpirationTime>2013-10-08T17:27:06</ExpirationTime>
        <Id>13a984f8-5d97-4f87-aa52-7523849cc6f5</Id>
      </LockTicket>
      <Comment/>
      <PeriodOptions xmlns:a="http://schemas.datacontract.org/"/>
      <ChildCareCentreEntryReservationStatusType>VoorlopigIngeschreven</ChildCareCentreEntryReservationStatusType>
    </BasketItem>
  </BasketItems>
  <IsLocked>true</IsLocked>
  <ValidationResult i:nil="true"/>
</LockBasketResult>
 reservation.ChildCareCentreEntryReservationStatusTypeSpecified = true;
reservation.ChildCareCentreEntryReservationStatusTypeSpecified = true;