linq两个list合并查询

wozaiztam wozaiztam 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
 IList<ts_dynamic> dynamicList = null;
var allDynamic = (new ts_dynamicService()).GetAllDynamicByCompanyId(companyId);
if (!string.IsNullOrEmpty(userId) && string.IsNullOrEmpty(groupId))
dynamicList = allDynamic.Where(x => x.shareType == 4 && x.shareObjectId == userId)
.Select(y => new ts_dynamic { hirerId = y.hirerId, contentId = y.contentId }).ToList();//@我的动态
else if (string.IsNullOrEmpty(userId) && string.IsNullOrEmpty(groupId))
dynamicList = allDynamic.Select(y => new ts_dynamic { hirerId = y.hirerId, contentId = y.contentId }).ToList();
else
dynamicList = allDynamic.Where(x => x.shareType == 1 && x.shareObjectId == groupId)
.Select(y => new ts_dynamic { hirerId = y.hirerId, contentId = y.contentId }).ToList();//所在群组动态
//根据查询到的动态再去查附件
//上面代码已经取到动态表中的hirerId和contentId
//下面要根据上面的hirerId和contentId 去GetAllAttachByCompanyId取到的附件表中查询匹配的所有附件
var attachs = GetAllAttachByCompanyId(companyId).Where(x => x.hirerId==dynamicList//此处并没有dynamicList.hireId,但是数据库中是有的);



请问linq怎么写啊?
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
wozaiztam
LINQ 8,492 成员 4,736 内容