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);

猜你喜欢

转载自www.cnblogs.com/kexb/p/9199085.html