Пример #1
0
 /// <summary>
 /// 用于向 PostItems EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToPostItems(PostItem postItem)
 {
     base.AddObject("PostItems", postItem);
 }
Пример #2
0
        public int CreatePostItem(string postID, FullPostItem postItem)
        {
            int ipostID = int.Parse(postID);
            using (MooDB db = new MooDB())
            {
                Post post = (from p in db.Posts
                             where p.ID == ipostID
                             select p).SingleOrDefault<Post>();
                if (post == null) throw new ArgumentException("无此帖子");

                PostItem newPostItem = new PostItem()
                {
                    Content = postItem.Content,
                    CreateTime = DateTime.Now,
                    CreatedBy = Security.CurrentUser.GetDBUser(db),
                    Post = post,
                };
                post.ReplyTime = DateTime.Now;

                Access.Required(db, newPostItem, Function.CreatePostItem);

                db.PostItems.AddObject(newPostItem);
                db.SaveChanges();
                return newPostItem.ID;
            }
        }
Пример #3
0
 /// <summary>
 /// 创建新的 PostItem 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 /// <param name="content">Content 属性的初始值。</param>
 /// <param name="createTime">CreateTime 属性的初始值。</param>
 public static PostItem CreatePostItem(global::System.Int32 id, global::System.String content, global::System.DateTime createTime)
 {
     PostItem postItem = new PostItem();
     postItem.ID = id;
     postItem.Content = content;
     postItem.CreateTime = createTime;
     return postItem;
 }