实体框架中的lambda表达式

编程入门 行业动态 更新时间:2024-10-28 18:22:32
本文介绍了实体框架中的lambda表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用实体框架我需要得到一个用户朋友图中的图片 这是表格的图表

iam using entity framwork i need to get a user friends the diagram are in the picture this is the diagram of the tables

Int64 userID =1; ctx.Users.Where(x => x.FriendShips.All(y => y.Accepted == true && y.CreatorID == userID)).ToList();

推荐答案

这可能有助于了解您期望的结果以及您实际获得的结果。 目前你在这里有什么 Well it might help to know what results you are expecting and what you are actually getting. currently what you have here y => y.Accepted == true && y.CreatorID == userID)

只会在一个方向上获得友谊。意思是如果其他人创建了朋友请求并且您的用户接受了它,那么他们将成为'FriendId'。如果两个用户的友谊表中都有一行,那么这并不重要,但假设1个关系的1个友情记录,则必须添加

will only get the friendships in one direction. meaning if someone else created the friend request and your user accepted it, then they would be the 'FriendId'. If there is a row put into the Friendship table for both users then this doesn't matter, but assuming 1 friendship record for 1 relationship, you'd have to add the

y => && y.FriendId== userID)

as well.

更多推荐

实体框架中的lambda表达式

本文发布于:2023-11-07 04:40:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表达式   实体   框架   lambda

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!