Здравствуйте, я получаю эту ошибку, когда дважды получаю доступ к одному и тому же методу общего хранилища внутри одного метода.
var polyTables = _vehicleService.GetAll().ToList()
.Select(p => new PolyTable
{
VinNumber = p.ChassisNumber ?? "-",
BrandName = p.BrandName,
FirstRegisterDate = p.FirstRegistrationDate,
ModelCode = p.ModelCode,
Plate = p.Plate ?? "-",
CreatedBy = 1,
IsActive = true,
AuthorizedServiceId = p.AuthorizedServiceId,
Customer = GetLastCustomerName(p.Id, periodicCodes)
}).ToList();
Heres Моя ошибка
private string GetLastCustomerName(string vehicleId,IEnumerable<PeriodicCode> periodicCodes)
{
var invoices = _invoiceService.GetByVehicle(vehicleId);
var lastInvoiceLine = _invoiceLineService.GetLastInvoiceLineByInvoices(invoices, periodicCodes);
var customer =new Customer();
if (lastInvoiceLine != null )
customer = _customerService.GetById(lastInvoiceLine.CustomerNumber);
return customer.Name + " " + customer.SurName;
}
Heresme Общий метод репозитория
public IEnumerable<T> Find(Expression<Func<T, bool>> predicate, params Expression<Func<T, object>>[] includes)
{
if (includes == null)
return Context.Set<T>().Where(predicate);
else
return includes.Aggregate(Context.Set<T>().Where(predicate).AsQueryable(), (current, includeProperty) => current.Include(includeProperty));
}
Вот метод GetByVehicle
public IEnumerable<Invoice> GetByVehicle(string vehicleId) =>
_genericRepository.Find(s => s.VehicleId == vehicleId);