示例#1
0
        static void Main(string[] args)
        {
            dbContext.Database.Migrate();
            Seeder.Seed();

            var query = dbContext.Authors.Include(x => x.Posts).Select(x => new ViewModels.Author
            {
                Id    = x.Id,
                Name  = x.Name + " " + x.LastName,
                Posts = x.Posts.Select(y => y.Id).ToList()
            }).Where(authorView => authorView.Id != 5)
                        .OrderBy(autoryView => autoryView.Name)
                        .ToArray();

            //var query = dbContext.Posts.Where(x => x.Content.ContainsText("egg")).ToArray();


            var john = dbContext.Authors.First(x => x.LastName == "Doe");
            var post = dbContext.Posts.Where(x => x.Title == "John Second Post Title").Include(x => x.Author).First();

            Console.WriteLine(post.Author == john);

            var textContains = dbContext.Posts.Where(x => !x.Content.ContainsText("egg")).ToArray();

            var programmersBlog = dbContext.Blogs.First();
            var last15DaysJohnsPostsFromBlog = new LastPosts(15) && new ByAuthor(john) && new FromBlog(programmersBlog.Id);

            var posts = dbContext.Posts.Where(last15DaysJohnsPostsFromBlog).ToList();

            posts.ForEach(Console.WriteLine);
        }
        private void InitReplyToTopic()
        {
            DataRow    topic      = DB.topic_info(TopicID);
            TopicFlags topicFlags = new TopicFlags(SqlDataLayerConverter.VerifyInt32(topic["Flags"]));

            // Ederon : 9/9/2007 - moderators can reply in locked topics
            if (topicFlags.IsLocked && !PageContext.ForumModeratorAccess)
            {
                Response.Redirect(Request.UrlReferrer.ToString());
            }
            SubjectRow.Visible = false;
            Title.Text         = GetText("reply");

            // add topic link...
            PageLinks.AddLink(Server.HtmlDecode(topic ["Topic"].ToString()), YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.posts, "t={0}", TopicID));
            // add "reply" text...
            PageLinks.AddLink(GetText("reply"));

            // show attach file option if its a reply...
            if (PageContext.ForumUploadAccess)
            {
                NewTopicOptionsRow.Visible = true;
                TopicAttach.Visible        = true;
                TopicAttachLabel.Visible   = true;
                TopicWatch.Visible         = false;
                TopicWatchLabel.Visible    = false;
                TopicAttachBr.Visible      = false;
            }

            if (YAF.Classes.Config.IsDotNetNuke || YAF.Classes.Config.IsRainbow || YAF.Classes.Config.IsPortal)
            {
                // can't use the last post iframe
                LastPosts.Visible    = true;
                LastPosts.DataSource = DB.post_list_reverse10(TopicID);
                LastPosts.DataBind();
            }
            else
            {
                LastPostsIFrame.Visible = true;
                LastPostsIFrame.Attributes.Add("src", string.Format("{0}framehelper.aspx?g=lastposts&t={1}", YafForumInfo.ForumRoot, TopicID));
            }
        }