MongoDB.Bson.Serialization.Conventions.ConventionProfile.SetIgnoreIfNullConvention C# (CSharp) Method

SetIgnoreIfNullConvention() public method

Sets the ignore if null convention.
public SetIgnoreIfNullConvention ( IIgnoreIfNullConvention convention ) : ConventionProfile
convention IIgnoreIfNullConvention An ignore if null convention.
return ConventionProfile
        public ConventionProfile SetIgnoreIfNullConvention(IIgnoreIfNullConvention convention)
        {
            IgnoreIfNullConvention = convention;
            return this;
        }

Usage Example

        public void AfterPropertiesSet()
        {
            var defaultProfile = ConventionProfile.GetDefault();
            _profile = new ConventionProfile();
            _filter = new ConventionFilterHelper(IncludeFilters, ExcludeFilters);

            _profile.SetDefaultValueConvention(DefaultValueConvention ?? defaultProfile.DefaultValueConvention);
            _profile.SetElementNameConvention(ElementNameConvention ?? defaultProfile.ElementNameConvention);
            _profile.SetExtraElementsMemberConvention(ExtraElementsMemberConvention ?? defaultProfile.ExtraElementsMemberConvention);
            _profile.SetIdGeneratorConvention(IdGeneratorConvention ?? defaultProfile.IdGeneratorConvention);
            _profile.SetIdMemberConvention(IdMemberConvention ?? defaultProfile.IdMemberConvention);
            _profile.SetIgnoreExtraElementsConvention(IgnoreExtraElementsConvention ?? defaultProfile.IgnoreExtraElementsConvention);
            _profile.SetIgnoreIfDefaultConvention(IgnoreIfDefaultConvention ?? defaultProfile.IgnoreIfDefaultConvention);
            _profile.SetIgnoreIfNullConvention(IgnoreIfNullConvention ?? defaultProfile.IgnoreIfNullConvention);
            _profile.SetMemberFinderConvention(MemberFinderConvention ?? defaultProfile.MemberFinderConvention);
            _profile.SetSerializationOptionsConvention(SerializationOptionsConvention ?? defaultProfile.SerializationOptionsConvention);

            BsonClassMap.RegisterConventions(_profile, _filter.Filter);
        }