using AutoLot.Dal.EfStructures;

using AutoLot.Dal.Models.Entities;

using AutoLot.Dal.Repos.Base;

using AutoLot.Dal.Repos.Interfaces;

using Microsoft.EntityFrameworkCore;

Измените класс на public, унаследуйте его от BaseRepo, реализуйте ICreditRiskRepo и добавьте два обязательных конструктора:

namespace AutoLot.Dal.Repos

{

  public class CreditRiskRepo : BaseRepo, ICreditRiskRepo

  {

    public CreditRiskRepo(ApplicationDbContext context) : base(context)

    {

    }

    internal CreditRiskRepo(

      DbContextOptions options)

    : base(options)

    {

    }

  }

}

<p id="AutBody_Root1004"><strong>Хранилище данных о заказчиках</strong></p>

Откройте файл класса CustomerRepo.cs и поместите в его начало приведенные далее операторы using:

using System.Collections.Generic;

using System.Linq;

using AutoLot.Dal.EfStructures;

using AutoLot.Dal.Models.Entities;

using AutoLot.Dal.Repos.Base;

using AutoLot.Dal.Repos.Interfaces;

using Microsoft.EntityFrameworkCore;

Измените класс на public, унаследуйте его от BaseRepo, реализуйте ICustomerRepo и добавьте два обязательных конструктора:

namespace AutoLot.Dal.Repos

{

  public class CustomerRepo : BaseRepo, ICustomerRepo

  {

    public CustomerRepo(ApplicationDbContext context)

      : base(context)

    {

    }

    internal CustomerRepo(

      DbContextOptions options)

      : base(options)

    {

    }

  }

}

Наконец, добавьте метод, который возвращает все записи Customer с их заказами, отсортированные по значениям LastName:

public override IEnumerable GetAll()

  => Table

      .Include(c => c.Orders)

      .OrderBy(o => o.PersonalInformation.LastName);

<p id="AutBody_Root1005"><strong>Хранилище данных о производителях</strong></p>

Откройте файл класса MakeRepo.cs и поместите в его начало перечисленные ниже операторы using:

using System.Collections.Generic;

using System.Linq;

using AutoLot.Dal.EfStructures;

using AutoLot.Dal.Models.Entities;

using AutoLot.Dal.Repos.Base;

using AutoLot.Dal.Repos.Interfaces;

using Microsoft.EntityFrameworkCore;

Измените класс на public, унаследуйте его от BaseRepo, реализуйте IMakeRepo и добавьте два обязательных конструктора:

namespace AutoLot.Dal.Repos

{

  public class MakeRepo : BaseRepo, IMakeRepo

  {

    public MakeRepo(ApplicationDbContext context)

      : base(context)

     {

    }

    internal MakeRepo(

      DbContextOptions options)

      : base(options)

    {

    }

  }

}

Переопределите методы GetAll(), чтобы они сортировали значения Make по названиям:

public override IEnumerable GetAll()

  => Table.OrderBy(m => m.Name);

public override IEnumerable GetAllIgnoreQueryFilters()

  => Table.IgnoreQueryFilters().OrderBy(m => m.Name);

<p id="AutBody_Root1006"><strong>Хранилище данных о заказах</strong></p>

Откройте файл класса OrderRepo.cs и поместите в его начало следующие операторы using:

using AutoLot.Dal.EfStructures;

using AutoLot.Dal.Models.Entities;

using AutoLot.Dal.Repos.Base;

using AutoLot.Dal.Repos.Interfaces;

using Microsoft.EntityFrameworkCore;

Измените класс на public, унаследуйте его от BaseRepo и реализуйте IOrderRepo:

namespace AutoLot.Dal.Repos

{

  public class OrderRepo : BaseRepo, IOrderRepo

  {

    public OrderRepo(ApplicationDbContext context)

      : base(context)

    {

    }

    internal OrderRepo(

      DbContextOptions options)

      : base(options)

    {

    }

  }

}

Перейти на страницу:

Похожие книги