Here's how I would do it in one request based on the information you provided.
var posts = await _context.Post
.Where(post =>
_context.BlogPost.Any(bp => bp.BlogId == blogId && bp.PostId == post.PostId)
)
.ToListAsync();
Here's how I would do it in two queries to use Containsbased on the information you provided.
var postIds = await _context.BlogPost
.Where(bp => bp.BlogId = blogId)
.Select(bp => bp.PostId)
.ToArrayAsync();
var posts = await _context.Post
.Where(p => postIds.Contains(p.PostId))
.ToListAsync();
, EntityFramework, Post BlogPost.
var posts = await _context.BlogPost
.Where(bp => bp.BlogId == blogId)
.Select(bp => bp.Post)
.ToListAsync();
, EntityFramework, , Posts from Blog, - BlogPost EntityFramework , #.
var posts = await _context.Blog
.Where(b => b.BlogId == blogId)
.SelectMany(b => b.Posts)
.ToListAsync();
, EntityFramework - BlogPost, , .
var posts = await _context.Blog
.Where(b => b.BlogId == blogId)
.SelectMany(b => b.BlogPosts)
.Select(bp => bp.Post)
.ToListAsync();
var posts = await _context.Blog
.Where(b => b.BlogId == blogId)
.SelectMany(b => b.BlogPosts.Select(bp => bp.Post))
.ToListAsync();
, EntityFramework - SQL. , SQL, , , EntityFramework. , EntityFramework, EntityFramework #, EntityFramework, LINQ. . LINQ EntityFramework.