示例#1
0
 public Post[] GetAllPosts()
 {
     using (var context = new EfCore2020Entities())
     {
         context.NoLazyLoading();
         var    items = context.Posts;
         Post[] posts = items.ToArray <Post>();
         return(posts);
     }
 }
示例#2
0
        public Comment[] GetComments(Post post)
        {
            using (var context = new EfCore2020Entities())
            {
                context.NoLazyLoading();
                var item = context.Posts.Where(x => x.Equals(post)).FirstOrDefault();

                return(item.Comments.ToArray());
            }
        }
示例#3
0
 public Post GetPostById(int id)
 {
     using (var context = new EfCore2020Entities())
     {
         //context.Configuration.LazyLoadingEnabled = false;
         //context.Configuration.ProxyCreationEnabled = false;
         context.NoLazyLoading();
         var item = context.Posts.Where(x => x.PostId == id).FirstOrDefault();
         Console.WriteLine(item.ToString());
         return(item);
     }
 }