using (var context = new BloggingContext())
{
var blogs = context.Blogs
.Include(blog => blog.Posts)
.ThenInclude(post => post.Author)
.ThenInclude(author => author.Photo)
.Select(Blogs => new BlogsItem{
Name = Blogs.Posts.Author.Name
});
}
假设 Blogs Posts Author为1对1关系
Name = Blogs.Posts.Author.Name 如果Blogs.Posts 为空 或者Blogs.Posts.Author为空会报错,这种如何处理呢?
Translation:
Assume that Blogs Posts Author is a one-to-one relationship
Name = Blogs.Posts.Author.Name If Blogs.Posts is empty or Blogs.Posts.Author is empty, it will report an error. How do I handle this?