This is the model that OData Api is going to serialize and return as an xml or json result

using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using Orchard.Blogs.Models;

namespace ODataBlog.Models
{

// DataContract indicates that this class is serializable and DataMember indicates that the field is going to be serialized

    [DataContract]
    public class Blog 
    {
        [DataMember]
        public int Id { get; private set; }
        [DataMember]
        public string Title { get; private set; }
        [DataMember]
        public string Description { get; private set; }
        [DataMember]
        public int PostCount { get; private set; }

        public Blog(BlogPart p)
        {
            Id = p.Id;
            Title = p.Name;
            Description = p.Description;
            PostCount = p.PostCount;
        }
    }
}

Last edited Dec 30, 2012 at 9:00 PM by fotisgpap, version 2

Comments

No comments yet.