✅ Remove many to many with select
So here is the code snippet,
If I add something to any of the Lists LikedBy, DislikedBy and SeenBy they are added, but if I remove, they are not removed
I read the docs and I know that LikedBy, DislikedBy and SeenBy are not tracked, but I honestly cant find any smart way of doing this except pulling all of the LikedBy, DislikedBy and SeenBy but that is memory inefficient and I have multiple DB calls, so is there something like this only for lists
3 Replies
depending on what EF version you are using, you can do
_ctx.Posts.Include(x => x.LikedBy.Where(y => y.Id == _userId))
to filter down the collection.Im using Ef Core 7, wow I didnt know that was a feature, thank you so so so so so much, this is what I needed
I love you, I've been going at this for 7 hours trying to find a way and i created such a complex solution, but this is so easy and elegant, thank you so so so so much
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.