为了账号安全,请及时绑定邮箱和手机立即绑定

检查ac#列表中的某些项目是否相同

检查ac#列表中的某些项目是否相同

C#
智慧大石 2022-01-09 16:21:27
我想根据列表中存在的项目检查列表中的某些项目是否相同。List<ProductDetailDTO> productDTOs;ProductDetailDTO 是 -public class ProductDetailDTO{    public int ProductId { get; set; }    public string Name { get; set; }    public string Category { get; set; }    public byte[] Image { get; set; }    public string Description { get; set; }    public string Brand { get; set; }    public string GUID { get; set; }    public string VariantName { get; set; }    public string VariantValue { get; set; }    public decimal Price { get; set; }}现在,我想一起显示所有具有相同 GUID 的 VariantName 和 VariantValue。我怎样才能做到这一点?
查看完整描述

1 回答

?
回首忆惘然

TA贡献1847条经验 获得超11个赞

试试这个


productDTOs.GroupBy(x => x.GUID,(key,item) => new

            {

                VariantName= item.Select(y=>y.VariantName),

                VariantValue = item.Select(y => y.VariantValue),


            }).ToList()


查看完整回答
反对 回复 2022-01-09
  • 1 回答
  • 0 关注
  • 130 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号