Linq multiple columns; get weird results

So, m.SourceCollection has 1000 entries, which includes a collection of elements with the Lat and Lon attributes; Nothing more. I ran this:

var results = from locs in m.PlacesBeen
                      group locs by new {locs.Lat, locs.Lon }
                          into myGroup
                           select new { Lat = myGroup.Key.Lat, Lon = myGroup.Key.Lon };

      

The next breakpoint, "results", contains three items. I'm just trying to make a group and get unique sums just like in SQL.

0


a source to share


1 answer


This query looks fine - what results did you expect?

Btw, here's an easier way to write the same query:



var results = 
  m.PlacesBeen.Select (loc => new {locs.Lat, locs.Lon }).Distinct();

      

+1


a source







All Articles