private static ISqlRuntimeConfigurationProvider BuildRuntimeConfigurationProvider() { IEnumerable <ISqlResourceConfiguration> resourceConfigurations = ResourceConfigurationBuilder.Build <ISqlPropertyConfiguration, ISqlResourceConfiguration, ISqlModelConfiguration>(typeof(SqlResourceConfigurationBuilder <>)); // No need to register these with the DI container, as they are only used during startup ISqlParamaterProvider sqlParamaterProvider = new SqlParameterProvider(); ISqlGenerator generator = new SqlGenerator(sqlParamaterProvider); ISqlExpressionBuilder sqlExpressionBuilder = new SqlExpressionBuilder(sqlParamaterProvider, new SqlClassProvider()); Dictionary <Type, ISqlRuntimeConfiguration <IRestResource> > runtimeConfigurations = new Dictionary <Type, ISqlRuntimeConfiguration <IRestResource> >(); foreach (ISqlResourceConfiguration configuration in resourceConfigurations) { string selectAll = generator.SelectAll(configuration); string selectById = generator.SelectById(configuration); string deleteById = generator.DeleteById(configuration); string updateById = generator.Update(configuration); string insert = generator.Insert(configuration); var createObjectRelationalMapFunc = typeof(ISqlExpressionBuilder) .GetMethod(nameof(ISqlExpressionBuilder.CreateObjectRelationalMap)) .MakeGenericMethod(configuration.ResourceType) .Invoke(sqlExpressionBuilder, new[] { configuration }) as Func <IDatabaseResultReader, IRestResource>; var getPrimaryKeySqlParameterFunc = sqlExpressionBuilder.GetPrimaryKeySqlParameter(configuration.PrimaryIdentifier); var getSqlParametersForCreationFunc = sqlExpressionBuilder.GetSqlParametersForCreation(configuration); var getSqlParametersForUpdatingFunc = sqlExpressionBuilder.GetSqlParametersForUpdating(configuration); var runtimeConfiguration = Activator.CreateInstance( typeof(SqlRuntimeConfiguration <>).MakeGenericType(configuration.ResourceType), configuration, createObjectRelationalMapFunc, getPrimaryKeySqlParameterFunc, getSqlParametersForCreationFunc, getSqlParametersForUpdatingFunc, selectAll, selectById, deleteById, insert, updateById) as ISqlRuntimeConfiguration <IRestResource>; runtimeConfigurations.Add(configuration.ResourceType, runtimeConfiguration); } return(new SqlRuntimeConfigurationProvider(runtimeConfigurations)); }