WCF休息服务日期格式json post get

时间:2015-06-02 05:53:25

标签: json wcf

这是我的Context Class&接口

        [DataContract]
        public class RatingsTransaction
        {
            public DateTime ServerDate;
            [Key]
            [DataMember]
            public Int32 RatID { get; set; }
            [DataMember]
            public Int32 RatingID { get; set; }
            [DataMember]
            public Int32 TransportID { get; set; }
            [DataMember]
            public Int32 UserID { get; set; }
            [DataMember]
            public Boolean IsActive { get; set; }
            [DataMember]
            public Int32 CreatedBy { get; set; }
            [DataMember]
            public DateTime CreatedDate { get { return ServerDate; } set { ServerDate = DateTime.Now; } }
            [DataMember]
            public Int32 ModifiedBy { get; set; }
            [DataMember]
            public DateTime ModifiedDate { get { return ServerDate; } set { ServerDate = DateTime.Now; } }
        }

        [OperationContract]
        [WebGet(UriTemplate = "ratingstransaction/{ID}")]
        RatingsTransaction getRatingsTransaction(string ID);

        public RatingsTransaction getRatingsTransaction(string ID)
        {
            try
            {
                Int32 _id = Convert.ToInt32(ID);
                using (var _WDSObj = new WDS_MODEL())
                {
                    return _WDSObj._RatingsTransaction.SingleOrDefault(p => p.RatID == _id);
                }
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }

当我致电此服务时

http://localhost:49188/rest/PRODUCT_SERVICE.svc/ratingstransaction/3

输出:

{"getRatingsTransactionResult":{"CreatedBy":13,"CreatedDate":"\/Date(1433159097577+0530)\/","IsActive":true,"ModifiedBy":13,"ModifiedDate":"\/Date(1433159097577+0530)\/","RatID":3,"RatingID":3,"TransportID":3,"UserID":240}}

预期日期格式不正确。如何解决此问题。请建议

0 个答案:

没有答案