Skip to content

Commit

Permalink
IgnoreIfNullConvention (#61)
Browse files Browse the repository at this point in the history
Co-authored-by: José Luis Latorre Millas <[email protected]>
  • Loading branch information
joslat and joslat authored Apr 5, 2022
1 parent b5075d8 commit 8f2f2c2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Context/IMongoDatabaseBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ IMongoDatabaseBuilder RegisterConventionPack(
IMongoDatabaseBuilder RegisterDefaultConventionPack();

IMongoDatabaseBuilder RegisterCamelCaseConventionPack();


IMongoDatabaseBuilder RegisterIgnoreIfNullConventionPack();

IMongoDatabaseBuilder ConfigureCollection<TDocument>(
IMongoCollectionConfiguration<TDocument> configuration) where TDocument : class;

Expand Down
10 changes: 10 additions & 0 deletions src/Context/Internal/MongoDatabaseBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(IBsonSerializer<T> serializer)
{
_registrationSerializerActions.Add(
Expand Down

0 comments on commit 8f2f2c2

Please sign in to comment.