Linq去重 不用实现IEqualityComparer接口的方法超级简单

RskFactorRelation.Instance.GetCache<RskFactorRelation>(true).Where(x => !string.IsNullOrEmpty(x.SourceProductTable) && !string.IsNullOrEmpty(x.SourceProductId))
                        .GroupBy(x=>x.SourceProductTable+","+x.SourceProductId)
                        .Select(x=>x.FirstOrDefault())
                        .ToDictionary(x => x.IndexPriceFactorId);

 

posted on 2018-06-19 16:15  听哥哥的话  阅读(151)  评论(0编辑  收藏  举报

导航