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; }
/// <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; }
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; } }
/// <summary> /// Deprecated Method for adding a new object to the SubforumEntities EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSubforumEntities(SubforumEntity subforumEntity) { base.AddObject("SubforumEntities", subforumEntity); }