Web Api z AutoMapperem

0

Witam,
Mam problem z projektem. Utworzyłem model bazy danych, na jego podstawie wygenerowałem EntityFrameworkiem baze danych. Dodałem jakieś wartości. Zrobiłem generyczne reozyorium, dodałem automappera i structure mappera. Generalnie mam osiem tabel w bazie i gdy próbuję wyciągnąć dane to mi się wykrzacza. Co może być nie tak? Wszędzie piszą o pliku DefaultRegistry.cs ale nie wiem co tam zmienić. Poniżej kod tej klasy i log błędu. Proszę o pomoc

public class DefaultRegistry : Registry {
        #region Constructors and Destructors

        public DefaultRegistry() {           
            Scan(x =>
            {
                x.TheCallingAssembly();
                x.WithDefaultConventions();
            });
            var profiles = from t in typeof(DefaultRegistry).Assembly.GetTypes()
                           where typeof(Profile).IsAssignableFrom(t)
                           select (Profile)Activator.CreateInstance(t);

            var config = new MapperConfiguration(cfg =>
            {
                foreach (var profile in profiles)
                {
                    cfg.AddProfile(profile);
                }
            });

            var mapper = config.CreateMapper();                       
            For<IMapperConfiguration>().Use(config);
            For<IMapper>().Use(mapper);

            RegisterRepositories(mapper);
        }

        private void RegisterRepositories(IMapper mapper)
        {
            For<IActionFolderService>().Use<ActionFoldersService>().Ctor<IMapper>().Is(mapper);
            For<IActionService>().Use<ActionService>().Ctor<IMapper>().Is(mapper);
            For<IChallengesService>().Use<ChallengesService>().Ctor<IMapper>().Is(mapper);
            For<ILevelsService>().Use<LevelsService>().Ctor<IMapper>().Is(mapper);
            For<IPointCategoriesService>().Use<PointCategoriesService>().Ctor<IMapper>().Is(mapper);
            For<ISitesService>().Use<SitesService>().Ctor<IMapper>().Is(mapper);
            For<IUsersService>().Use<UsersService>().Ctor<IMapper>().Is(mapper);
        }

        #endregion
    }

{"No default Instance is registered and cannot be automatically determined for type 'IRepository<Users>'\r\n\r\nThere is no configuration specified for IRepository<Users>\r\n\r\n

1.) new UsersService(Default of IRepository<Users>, Value: AutoMapper.Mapper)\r\n
2.) BLL.Services.UsersService.UsersService\r\n
3.) Instance of BLL.Services.UsersService.IUsersService (BLL.Services.UsersService.UsersService)\r\n
4.) new UserController(Default of IUsersService)\r\n
5.) WebApi.Controllers.UserController\r\n
6.) Instance of WebApi.Controllers.UserController\r\n
7.) Container.GetInstance(WebApi.Controllers.UserController)\r\n"}

1

There is no configuration specified for IRepository<users> - opis chyba dość oczywisty? Kontener chce utworzyć instancję IRepository<users> (zapewne któryś serwis go wymaga), a nie może, bo nie zna jego implementacji. Po prostu zarejestruj swoje "repozytorium" w kontenerze.

W ogóle, to wesoły ten kod. Metoda nazywa się RegisterRepositories i rejestruje osiem 1 serwisów, za to żadnego repozytorium.

1 Tak naprawdę to siedem, ale "osiem" lepiej brzmi.

1 użytkowników online, w tym zalogowanych: 0, gości: 1