admin管理员组文章数量:1122832
I am having an issue with the Linq Distinct Method. I have a List of LocationID's
- B A01A
- B A01A
- A A01A
- A A01A
- A A01A
As you can see, there are only two distinct values here. However, When they are passed through this code block here
var result = rootObject.OrderLines.Where(orderLine =>
orderLine.OrderAllocations
.Where(y => y.StatusID != 250)
.Select(y => y.LocationID)
.Distinct()
.Count() == 1);
The count is 1 when in reality it should be 2.
However when I Modify the string with a .Concat()
or .Reverse()
method like below
var result = rootObject.OrderLines.Where(orderLine =>
orderLine.OrderAllocations
.Where(y => y.StatusID != 250)
.Select(y => y.LocationID.Reverse())
.Distinct()
.Count() == 1);
the count is correct. not sure what is happening
本文标签: cDistinct method ony works when modifying stringStack Overflow
版权声明:本文标题:c# - Distinct method ony works when modifying string - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736304000a1932075.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论