c# - 优化 linq 查询的更好方法
问题描述
我在 C# 应用程序中编写了一个 linq 查询来获取 auth 用户所属的应用程序的名称
var authApplicationRepository = AuthApplicationRepository.GetAllAsList();
var authUserRepository = AuthUserRepository.GetAllAsList();
你认为有没有更好更短的方法来结合这两条线
//Get the name of the application the auth user belongs to
var authUserApplicationId = authUserRepository
.Where(x => x.Id == userChangeRequest.AuthUserId)
.Select(x => x.ApplicationId)
.FirstOrDefault();
var authUserApplicationName = authApplicationRepository
.Where(x => x.Id == authUserApplicationId)
.Select(x => x.Description)
.FirstOrDefault();
解决方案
推荐阅读
- python - 从字符串变量创建列表
- python - 如何根据analyze_recording()的“分析”中包含的信息在psynet中试用后显示自定义反馈?
- python - 无服务器部署不创建 API 网关
- string - 将对象列表转换为字符串列表
- python - 标准输出标准输入节点到 python
- python - 根据索引和列将填充 DataFrame 合并到掩码中
- python - 通过 udp python 发送和教授消息
- javascript - 尝试将 FontAwesome 放入正文时出现 Next.js 链接错误
- flutter - Flutter/Dart firestore 返回 LinkedMap - 如何使用它?
- arrays - 从一个值数组正确移位到另一个值数组有点难的问题