以下代码为我提供了我需要的结果,但有人可以建议如何更好地编写它吗?我确信这是一种更有效的方法。 感谢。
private bool IsLocation(Guid _vID, Guid OrganisationId)
{
var vehicle = _vehilceRepository.GetSingle(c => c.vehicleId == _vID);
var clients = _clientRepository.GetList(c => c.OrganisationID == OrganisationId);
foreach (var client in clients)
{
var locations = _LocationRepository.GetList(c => c.ClientID == client.ClientID);
if (locations.Count > 0)
{
foreach (var location in locations)
{
if (location.LocationId == vehicle.LocationID)
{
return true;
}
}
}
}
return false;
}