我正在尝试获取每个类别中最近的位置。谁能帮我做到这一点?
var xml = new XElement("Locations",
locations.OrderBy(n => n.CategoryID)
.ThenBy(n => distance(lat, lon, (double)n.Latitude, (double)n.Longitude))
.Where(n => (distance(lat, lon, (double)n.Latitude, (double)n.Longitude) <= 5))
.Select(location =>
new XElement("Location",
new XAttribute("CategoryID", location.CategoryID),
new XElement("Category", location.Category),
new XElement("LocationID", location.LocationID),
new XElement("LocationName", location.LocationName),
new XElement("Latitude", location.Latitude),
new XElement("Longitude", location.Longitude),
new XElement("Distance", distance(lat, lon, (double)location.Latitude, (double)location.Longitude)),
new XElement("Status", (location.HasManagedHours ? "Managed Hours" : "Open"))
)));