public static LocationReference Map(this ILocationReferenceEntity entity, ILocationQuery locationQuery) { return(new LocationReference( entity.unstructuredLocation, entity.namedLocationId == null ? null : locationQuery.GetNamedLocation(entity.namedLocationId.Value), locationQuery.GetCountrySubdivision(entity.countrySubdivisionId), entity.localityId == null ? null : locationQuery.GetLocality(entity.localityId.Value)) { Id = entity.id }); }