public Post[] GetAllPosts() { using (var context = new EfCore2020Entities()) { context.NoLazyLoading(); var items = context.Posts; Post[] posts = items.ToArray <Post>(); return(posts); } }
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()); } }
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); } }