Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            var ctx = new DocumentContext("main");
            {
                var blogpost = new BlogPost()
                                   {
                                       Body = "gdfg",
                                       Topic = "fsdfs world",
                                   };

                blogpost.ReplyTo("Hej hej", "Roggan");
                blogpost.AddTag("NoSql");
                Console.WriteLine(blogpost.Id);
                ctx.GetCollection<BlogPost>().Add(blogpost);

                ctx.SaveChanges();
                Console.Read();
            }
            var query = from blogpost in ctx.GetCollection<BlogPost>().AsQueryable()
                                         where
                                             blogpost.Comments.Any(c => c.UserName == "Roggan") &&
                                             blogpost.CommentCount > 0
                                         select blogpost;

            List<BlogPost> result = query.ToList();

            foreach (BlogPost blogpost in result)
            {
                Console.WriteLine(blogpost.Topic);
            }
        }