Вот объекты:
Служба местоположения
Код: Выделить всё
[Table("LocationService")]
public class LocationService : FullAuditedEntity, IMustHaveTenant
{
public int TenantId { get; set; }
public int ServiceId { get; set; }
public int? LocationId { get; set; }
public int? UnitOfMeasureId { get; set; }
public decimal? Cost { get; set; }
public virtual Location Location { get; set; }
public virtual Service Service { get; set; }
public virtual UnitOfMeasure UnitOfMeasure { get; set; }
public virtual ICollection LocationServicePrices { get; set; }
}
}
Код: Выделить всё
[Table("LocationServicePrice")]
public class LocationServicePrice : FullAuditedEntity, IMustHaveTenant
{
public int TenantId { get; set; }
public int LocationServiceId { get; set; }
public int PricingTierId { get; set; }
public decimal? PricePerUnit { get; set; }
public virtual LocationService LocationService { get; set; }
public virtual PricingTier PricingTier { get; set; }
}
Код: Выделить всё
public async Task GetLocationServiceForEdit(NullableIdDto input)
{
LocationServiceEditDto locationServiceEditDto;
if (input.Id.HasValue)
{
locationServiceEditDto = await _locationServiceRepository.GetAll()
.Include(x => x.LocationServicePrices)
.Where(x => x.Id == input.Id)
.Select(x => new LocationServiceEditDto()
{
Id = x.Id,
TenantId = x.TenantId,
ServiceId = x.ServiceId,
LocationId = x.LocationId,
Cost = x.Cost,
MaterialUomId = x.UnitOfMeasureId,
MaterialUomName = x.UnitOfMeasure.Name,
Location = x.Location == null
? null
: new LocationNameDto { Name = x.Location.Name },
LocationServicePrices = x.LocationServicePrices
.Select(price => new LocationServicePriceDto()
{
Id = price.Id,
LocationServiceId = price.LocationServiceId,
PricePerUnit = price.PricePerUnit,
PricingTierName = price.PricingTier.Name,
PricingTierId = price.PricingTierId
}).ToList()
})
.FirstAsync();
}
else
{
locationServiceEditDto = new LocationServiceEditDto();
}
return locationServiceEditDto;
}
Но если мы можем видеть из базы данных
LocationService с идентификатором = 32

Имеет 5 цен на услуги
Как это исправить?
Подробнее здесь: https://stackoverflow.com/questions/783 ... p-net-core
Мобильная версия