我有一个类型供应商,它有一个属性 SupplierId 和另一个属性 NearestLocation,它是一个类型 SupplierLocation,SupplierLocation 由属性 SupplierId 和 DistanceFromDevice
class Supplier
{
public int SupplierId { get; set; }
public SupplierLocation NearestLocation { get; set; }
}
class SupplierLocation
{
public int SupplierId { get; set; }
public decimal DistanceFromDevice { get; set; }
public double Longitude { get; set; }
public double Latitude {get; set;}
}
我有一个供应商可以拥有多个位置的所有供应商位置的列表。我还计算了每个位置的 DistanceFromDevice 属性。我有一个列表,其 ID 可以在 SupplierLocations 列表中找到。
我想使用 linq 将我的供应商通过 SupplierId 加入到 SupplierLocation 并使用具有该特定供应商的所有位置的最小 DistanceFromDevice 值的 Location 填充 Supplier 类的 NearestLocation 属性。
希望这是有道理的。这可以使用linq完成吗?
提前谢谢了。保罗