locked
Return custom object? RRS feed

  • Question

  • [WebInvoke(Method = "GET")]
    [WebGet]
    public IEnumerable<WeightContract> GetWeights(string name)
    {
          // do something
    }


        [DataContract]
        [Serializable]
        public class WeightContract : ComplexObject
        {
            private string _name = String.Empty;
            private decimal _gmWeight = 0;
    
            public WeightContract(string name, double weight) {
                _name = name;
                _gmWeight = Convert.ToDecimal(weight);
            }
    
            [DataMember]
            public decimal GmWeight {
                get {
                    return this._gmWeight;
                }
                set {
                    this._gmWeight = value;
                }
            }
    
            [DataMember]
    
            public string Name {
                get {
                    return this._name;
                }
                set {
                    this._name = value;
                }
            }
        }
    config.SetServiceOperationAccessRule("GetWeights", ServiceOperationRights.AllRead);

    What am I doing wrong here?  I want to have a method in my oData Service that returns a custom type...but everytime I include the type in the method defintion the entire service craps out...if I change it to like IEnumerable<string> or something simple, then all works fine.

    Any Ideas? :/

    Steve

    Sunday, March 11, 2012 4:36 PM

All replies

  • How does it fail?

    Note that it should be possible to return custom type, but it will be treated as a complex value and currently the WCF DS Client doesn't support reading complex value responses.

    Thanks,


    Vitek Karas [MSFT]

    Sunday, March 11, 2012 9:09 PM
    Moderator