diff --git a/src/Context/IMongoDatabaseBuilder.cs b/src/Context/IMongoDatabaseBuilder.cs index bbc7920..cd8f226 100644 --- a/src/Context/IMongoDatabaseBuilder.cs +++ b/src/Context/IMongoDatabaseBuilder.cs @@ -17,7 +17,9 @@ IMongoDatabaseBuilder RegisterConventionPack( IMongoDatabaseBuilder RegisterDefaultConventionPack(); IMongoDatabaseBuilder RegisterCamelCaseConventionPack(); - + + IMongoDatabaseBuilder RegisterIgnoreIfNullConventionPack(); + IMongoDatabaseBuilder ConfigureCollection( IMongoCollectionConfiguration configuration) where TDocument : class; diff --git a/src/Context/Internal/MongoDatabaseBuilder.cs b/src/Context/Internal/MongoDatabaseBuilder.cs index 5a40428..6ff5a92 100644 --- a/src/Context/Internal/MongoDatabaseBuilder.cs +++ b/src/Context/Internal/MongoDatabaseBuilder.cs @@ -123,6 +123,16 @@ public IMongoDatabaseBuilder RegisterImmutableConventionPack() return this; } + public IMongoDatabaseBuilder RegisterIgnoreIfNullConventionPack() + { + RegisterConventionPack("IgnoreIfNull", new ConventionPack + { + new IgnoreIfNullConvention(true) + }, t => true); + + return this; + } + public IMongoDatabaseBuilder RegisterSerializer(IBsonSerializer serializer) { _registrationSerializerActions.Add(