Inheritance: System.Data.Objects.DataClasses.EntityObject
示例#1
0
        private Subforum GetSubforum(SubforumEntity subforumEntity)
        {
            string subforumName = subforumEntity.Name;
            SubforumEntity se = subforumEntity;
            Subforum subforum = new Subforum(se.Name);
            subforum.Description = se.Description;
            Dictionary<Postkey, Post> subforumPostsDic = new Dictionary<Postkey, Post>();
            // Get subforum`s posts
            IEnumerable<PostEntity> postsQuery = from p in ForumContext.PostEntities
                                                 where p.SubforumName == subforumName && p.ParentPostKeyId == -1
                                                 select p;
            foreach (PostEntity post in postsQuery)
            {
                Post p = PostEntityToPost(post);
                subforumPostsDic.Add(p.Key, p);
            }
            subforum.Posts = subforumPostsDic;
            subforum.TotalPosts = postsQuery.Count();

            // Get subforum`s moderator:
            List<string> moderatorsList = new List<string>();
            IEnumerable<ModeratorEntity> moderatorsQuery = from m in ForumContext.ModeratorEntities
                                                           where m.Subforum == subforumName
                                                           select m;
            foreach (ModeratorEntity moderator in moderatorsQuery)
            {
                moderatorsList.Add(moderator.Username);
            }
            subforum.ModeratorsList = moderatorsList;

            return subforum;
        }
示例#2
0
 /// <summary>
 /// Create a new SubforumEntity object.
 /// </summary>
 /// <param name="name">Initial value of the Name property.</param>
 public static SubforumEntity CreateSubforumEntity(global::System.String name)
 {
     SubforumEntity subforumEntity = new SubforumEntity();
     subforumEntity.Name = name;
     return subforumEntity;
 }
示例#3
0
        public bool AddSubforum(Subforum subforum)
        {
            try
            {
                SubforumEntity se = new SubforumEntity();
                se.Name = subforum.Name;
                se.Description = subforum.Description;
                ForumContext.SubforumEntities.AddObject(se);
                ForumContext.SaveChanges();
                return true;
            }
            catch (Exception)
            {

                throw;
            }
        }
示例#4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the SubforumEntities EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSubforumEntities(SubforumEntity subforumEntity)
 {
     base.AddObject("SubforumEntities", subforumEntity);
 }