public EntityUpdateHandler(DecodedDto dtoInfo, DecodedEntityClass entityInfo, IWrappedConfigAndMapper configAndMapper, DbContext context) { _dtoInfo = dtoInfo ?? throw new ArgumentNullException(nameof(dtoInfo)); _entityInfo = entityInfo ?? throw new ArgumentNullException(nameof(entityInfo)); _configAndMapper = configAndMapper ?? throw new ArgumentNullException(nameof(configAndMapper)); _context = context ?? throw new ArgumentNullException(nameof(context)); }
/// <summary> /// CrudServices needs the correct DbContext and the AutoMapper config /// </summary> /// <param name="context"></param> /// <param name="configAndMapper"></param> /// <param name="createNewDBContext"></param> public CrudServices(DbContext context, IWrappedConfigAndMapper configAndMapper, IDbContextService createNewDBContext) : base(context, configAndMapper, createNewDBContext) { if (context == null) { throw new ArgumentNullException("The DbContext class is null. Either you haven't registered GenericServices, " + "or you are using the multi-DbContext version, in which case you need to use the CrudServices<TContext> and specify which DbContext to use."); } }
public CreateMapper(DbContext context, IWrappedConfigAndMapper configAndMapper, Type tDto, DecodedEntityClass entityInfo) { var myGeneric = typeof(GenericMapper <,>); var genericType = myGeneric.MakeGenericType(tDto, entityInfo.EntityType); var constructor = genericType.GetConstructors().Single(); Accessor = GetNewGenericMapper(genericType, constructor).Invoke(context, configAndMapper, entityInfo); //Using Activator.CreateInstance with dynamic takes twice as long as LINQ new - see TestNewCreateMapper //Accessor = Activator.CreateInstance(genericType, context, configAndMapper, entityInfo); }
public void Setup() { var con = this.GetUniqueDatabaseConnectionString(nameof(PerfListMany)); _options = new DbContextOptionsBuilder <EfCoreContext>().UseSqlServer(con).Options; using (var context = new EfCoreContext(_options)) { context.Database.EnsureCreated(); if (!context.Books.Any()) { context.SeedDatabaseDummyBooks(100); } var utData = context.SetupSingleDtoAndEntities <BookListDto>(); _config = utData.ConfigAndMapper; } }
public GenericMapper(DbContext context, IWrappedConfigAndMapper wrappedMapper, DecodedEntityClass entityInfo) { _context = context ?? throw new ArgumentNullException(nameof(context)); _wrappedMapper = wrappedMapper ?? throw new ArgumentNullException(nameof(wrappedMapper)); _entityInfo = entityInfo ?? throw new ArgumentNullException(nameof(entityInfo)); }
internal GenericServicesSetupPart2(IServiceCollection services, IGenericServicesConfig publicConfig, IWrappedConfigAndMapper configAndMapper) { Services = services ?? throw new ArgumentNullException(nameof(services)); PublicConfig = publicConfig ?? throw new ArgumentNullException(nameof(publicConfig)); ConfigAndMapper = configAndMapper ?? throw new ArgumentNullException(nameof(configAndMapper)); }