我有一个GroupSummary
class
具有这样的属性:
public class GroupsSummary
{
public bool FooMethod()
{
////
}
public bool UsedRow { get; set; }
public string GroupTin { get; set; }
public string PayToZip_4 { get; set; }
public string PayToName { get; set; }
public string PayToStr1 { get; set; }
public string PayToStr2 { get; set; }
public string PayToCity { get; set; }
public string PayToState { get; set; }
public bool UrgentCare_YN { get; set; }
}
然后我有一个Dictionary
喜欢<string, List<GroupsSummary>
对于这些字典项中的每一项,我都想找到所有不同的地址,但是为我定义了不同地址的此类的属性是
PayToStr1,PayToStr2,PayToCity,PayToState
我知道我可以说些什么,mydictionartItem.select(t => t).Distinct().ToList()
但我认为这将比较该类的所有属性,这是错误的。那么我该如何解决呢?
var newDict = dict.ToDictionary(
x=>x.Key,
v=>v.Value.GroupBy(x=>new{x.PayToStr1, x.PayToStr2, x.PayToCity, x.PayToState})
.Select(x=>x.First())
.ToList());
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句