private static Post Convert(tblBlogs_Posts obj)
        {
            if (obj == null)
            {
                return null;
            }

            var post = new Post(obj.Id, obj.CreatedDate, obj.CreatedBy, obj.ModifiedDate, obj.ModifiedBy);
            BizObject<Post, int>.CopyFromObject(post, obj);
            if (obj.Categories != null)
            {
                post.Categories = new List<tblBlogs_Categories>(obj.Categories).ConvertAll(category => Convert(category));
            }
            return post;
        }
        public override int InsertPost(Post post)
        {
            var context = new BlogsEntities();
            var obj = new tblBlogs_Posts();
            post.CopyToObject(obj);

            if (post.Categories != null)
            {
                foreach (var category in post.Categories)
                {
                    var item = new tblBlogs_Categories {Id = category.Id};
                    context.AttachTo("tblBlogs_Categories", item);
                    obj.Categories.Add(item);
                }
            }

            context.AddTotblBlogs_Posts(obj);
            context.SaveChanges();
            return obj.Id;
        }