public IEnumerable<Blog> Get()
        {
            var ctx = new BloggingContext();
            int id = (++_i);
            var blog = new Blog
            {
                Url = "Testurl" + id,
                BlogId = id
            };
            ctx.Add(blog);

            return ctx.Blogs.OrderByDescending(b => b.BlogId).Take(3);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var ctx = new BloggingContext();
            List<Post> posts = new List<Post>();
            Post post = new Post
            {
                Title = "Title1"
            };
            posts.Add(post);

            var blog = new Blog
            {
                Url = "testurl",
                Posts = posts
            };
            ctx.Add(blog);
            ctx.SaveChanges();

            Console.ReadKey();
        }