public static void AddComment(Comment comment)
 {
     CommentsDataSource comDS = new CommentsDataSource();
     CommentEntry comm = new CommentEntry();
     Converter.CopyFields(comment, comm);
     comDS.AddComment(comm);
 }
 public static Comment FromTableEntry(CommentEntry comm)
 {
     return new Comment()
         {
             RowKey = comm.RowKey,
             Author = comm.Username,
             Body = comm.Comment,
             ParentName = comm.DatasetId,
             ParentType = comm.ParentType,
             ParentContainer = comm.PartitionKey,
             Posted = comm.PostedOn,
             Status = comm.Status,
             Subject = comm.Subject,
             Notify = comm.Notify,
             Type = comm.Type,
             Email = comm.Email
         };
 }
            public static CommentEntry CopyFields(Comment source, CommentEntry target)
            {
                if(!String.IsNullOrEmpty(source.RowKey))
                    target.RowKey = source.RowKey;

                target.Username = source.Author;
                target.Comment = source.Body;
                target.DatasetId = source.ParentName;
                target.ParentType = source.ParentType;
                target.PartitionKey = source.ParentContainer;
                target.PostedOn = source.Posted;
                target.Status = source.Status;
                target.Subject = source.Subject;
                target.Type = source.Type;
                target.Notify = source.Notify;
                target.Email = source.Email;

                return target;
            }
        private static string GetParentDisplayName(CommentEntry comm, Dictionary<string, string> requests, Dictionary<string, string> entities)
        {
            String result;

            if(comm.ParentType == "Request")
            {
                requests.TryGetValue(comm.DatasetId, out result);
            }
            else
            {
                entities.TryGetValue(comm.PartitionKey + comm.DatasetId, out result);
            }

            return result;
        }
 public void AddComment(CommentEntry item)
 {
     this.context.AddObject("Comments", item);
     this.context.SaveChanges();
 }
        //public IEnumerable<CommentEntry> GetByParentAndUser(string parentId, string container, string parentType, string user)
        //{
        //    var result = (from g in this.context.Comments
        //                  where g.DatasetId == parentId && g.PartitionKey == container && g.ParentType == parentType && g.Email == user
        //                  select g).AsEnumerable();

        //    return result;
        //}

        public void Update(CommentEntry entry)
        {
            this.context.UpdateObject(entry);
            this.context.SaveChanges();
        }