none
DataMemberAttribute Order attribute not being created consistently RRS feed

  • Question

  • I am using a WCF service. When I generate the service reference and view the Reference.cs file the order attribute is missing from some of the attributes. I am exposing a linq objects on the wcf service. The following is the specification on the WCF service generated by linq.

    Dataservice specification

    [

    global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_AssetID", DbType="Int NOT NULL"

     

    global::System.Runtime.Serialization.DataMemberAttribute

     

    public int

     

     

    {

     

    return this

     

     

    {

     

    if ((this._AssetID != value

     

    this._AssetID = value

     

    ;

     

    }

    }}

    The following is the equivalent block for the service reference.

     

    [System.Runtime.Serialization.

    DataMemberAttribute()]

     

    public int AssetID {

     

    get {

     

    return this.AssetIDField;

    }

     

    set {

     

    if ((this.AssetIDField.Equals(value) != true)) {

     

    this.AssetIDField = value;

     

    this.RaisePropertyChanged("AssetID");

    }

    }

    }

    This is causing problems because the order can get out of sync.

    I need to know why the order attribute is missing and what can be done to ensure that the order attribute is added to the client

    reference consistently.

     

    ))

     

    {

     

     

    set

    ._AssetID;

     

    }

     

     

    get

    AssetID

     

    {

     

    (Order=1)]

     

     

    )]

    [

     

    Wednesday, August 17, 2011 10:05 AM

All replies

  • Hello, can you format the code? Your code cannot be compiled... You may want to post the code to Word, and then copy from Word to the forum's text box.

    Anyway, to preserve data member order, you need to explicitly configure the Order property, as described on http://msdn.microsoft.com/en-us/library/ms729813.aspx.


    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    Windows Azure Technical Forum Support Team Blog
    Thursday, August 18, 2011 3:16 AM
  • Thanks for the reply. I am ordering the properties on the data service speciciation, the problem is that the order is not be passed over to the web service reference. I have added 2 code snippets one from the exposed Linq object. The reference.cs file on the client side i.e. the proxy.

    The exposed type is a Linq object, it contains the order of each parameter. The following code is the automatically generated output from Linq. This is being exposed in the interface

     public partial class LinqDataDataContext : System.Data.Linq.DataContext
     {

     [global::System.Runtime.Serialization.DataContractAttribute()]
     public partial class uspSHSearchResult
     {
      
      private int _AssetID;
      
      private int _PropertyID;
      
      private string _CorpSalesRef;
      
      private string _Clientcode;
      
      private string _MortgageAccNo;
      
      private string _Add1;
      
      private string _PostTown;
      
      private string _Postcode;
      
      private string _PropertyStatus;
      
      private System.Nullable<int> _PropertyStatusID;
      
      private string _AllocatedUser;
      
      private int _AllocatedUserID;
      
      private int _OnHold;
      
      private int _DaysOnMarket;
      
      public uspSHSearchResult()
      {
      }
      
      [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_AssetID", DbType="Int NOT NULL")]
      [global::System.Runtime.Serialization.DataMemberAttribute(Order=1)]
      public int AssetID
      {
       get
       {
        return this._AssetID;
       }
       set
       {
        if ((this._AssetID != value))
        {
         this._AssetID = value;
        }
       }
      }
      
      [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PropertyID", DbType="Int NOT NULL")]
      [global::System.Runtime.Serialization.DataMemberAttribute(Order=2)]
      public int PropertyID
      {
       get
       {
        return this._PropertyID;
       }
       set
       {
        if ((this._PropertyID != value))
        {
         this._PropertyID = value;
        }
       }
      }
      
      [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CorpSalesRef", DbType="Char(10) NOT NULL", CanBeNull=false)]
      [global::System.Runtime.Serialization.DataMemberAttribute(Order=3)]
      public string CorpSalesRef
      {
       get
       {
        return this._CorpSalesRef;
       }
       set
       {
        if ((this._CorpSalesRef != value))
        {
         this._CorpSalesRef = value;
        }
       }
      }
      
      [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Clientcode", DbType="VarChar(2) NOT NULL", CanBeNull=false)]
      [global::System.Runtime.Serialization.DataMemberAttribute(Order=4)]
      public string Clientcode
      {
       get
       {
        return this._Clientcode;
       }
       set
       {
        if ((this._Clientcode != value))
        {
         this._Clientcode = value;
        }
       }
      }
      

    On the client side the following was produced.

       [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
        [System.Runtime.Serialization.DataContractAttribute(Name="uspSHSearchResult", Namespace="http://schemas.datacontract.org/2004/07/DataService")]
        [System.SerializableAttribute()]
        public partial class uspSHSearchResult : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
           
            [System.NonSerializedAttribute()]
            private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private int AssetIDField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private int PropertyIDField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string CorpSalesRefField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string ClientcodeField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string MortgageAccNoField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string Add1Field;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string PostTownField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string PostcodeField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string PropertyStatusField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private System.Nullable<int> PropertyStatusIDField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string AllocatedUserField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private int AllocatedUserIDField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private int OnHoldField;
           
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private int DaysOnMarketField;
           
            [global::System.ComponentModel.BrowsableAttribute(false)]
            public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
                get {
                    return this.extensionDataField;
                }
                set {
                    this.extensionDataField = value;
                }
            }
           
            [System.Runtime.Serialization.DataMemberAttribute()]
            public int AssetID {
                get {
                    return this.AssetIDField;
                }
                set {
                    if ((this.AssetIDField.Equals(value) != true)) {
                        this.AssetIDField = value;
                        this.RaisePropertyChanged("AssetID");
                    }
                }
            }
           
            [System.Runtime.Serialization.DataMemberAttribute()]
            public int PropertyID {
                get {
                    return this.PropertyIDField;
                }
                set {
                    if ((this.PropertyIDField.Equals(value) != true)) {
                        this.PropertyIDField = value;
                        this.RaisePropertyChanged("PropertyID");
                    }
                }
            }
           
            [System.Runtime.Serialization.DataMemberAttribute(Order=2)]
            public string CorpSalesRef {
                get {
                    return this.CorpSalesRefField;
                }
                set {
                    if ((object.ReferenceEquals(this.CorpSalesRefField, value) != true)) {
                        this.CorpSalesRefField = value;
                        this.RaisePropertyChanged("CorpSalesRef");
                    }
                }
            }
           
            [System.Runtime.Serialization.DataMemberAttribute(Order=3)]
            public string Clientcode {
                get {
                    return this.ClientcodeField;
                }
                set {
                    if ((object.ReferenceEquals(this.ClientcodeField, value) != true)) {
                        this.ClientcodeField = value;
                        this.RaisePropertyChanged("Clientcode");
                    }
                }
            }

    Friday, August 19, 2011 2:26 PM