private Type CreateDynamicTypeForCollection(string collectionName, Dictionary <string, Type> providerTypes)
        {
            var fields = new Dictionary <string, Type>();

            providerTypes.Where(x => x.Key.StartsWith(collectionName + ".")).ToList()
            .ForEach(x => fields.Add(x.Key.Split('.').Last(), x.Value));
            return(DocumentTypeBuilder.CompileDocumentType(typeof(object), fields));
        }
        private Type CreateDynamicTypes(Func <string, bool> criteria, Dictionary <string, Type> providerTypes, Dictionary <string, Type> generatedTypes)
        {
            var fieldTypes = providerTypes.Where(x => criteria(x.Key));

            var fields = fieldTypes.ToDictionary(
                x => x.Key.Split('.').Last(),
                x => GetDynamicTypeForProviderType(x.Key, x.Value, providerTypes, generatedTypes));

            return(DocumentTypeBuilder.CompileDocumentType(typeof(object), fields));
        }