ConventionProfile is obsolete useIConventionPack Instead
c#, mongodb, mongodb-.net-driver
Solution
Well, it turned out that there is not library supplied implementation of IConventionPack. I had to handwrite an implementation of IConventionPack. Here is the code sample:
public class OpusOneConvention : IConventionPack
{
public IEnumerable<IConvention> Conventions
{
get { return new List<IConvention> { new IgnoreIfNullConvention(true) }; }
}
}
Followed by:
var conventions = new OpusOneConvention();
ConventionRegistry.Register("IgnoreIfNull", conventions, t => true);
So basically, all of your Conventions will go as an IEnumerable and then ConventionRegistry will be responsible for registering them.
thanks.
Note: As of version 1.8.1.20, you can use the ConventionPack as follows:
var conventions = new ConventionPack();
conventions.Add(new IgnoreIfNullConvention(true));
ConventionRegistry.Register("IgnoreIfNull", conventions, x => true);
Problem
I just updated my Mongo-C# driver from 1.6.1 to 1.8.1 and what I realized is that they have made a lot of functionality obsolete. one of the error that I am seeing due to deprecation is following: Convention Profile has been obsolete, Please replace it with IConventionsPack. Now, the problem is that there is not much documentation about IConeventionPack at all or how to use it. I am posting a small code snippet can anyone please suggest on how to handle this using IConventionPack? ``` var conventions = new ConventionProfile(); conventions.SetIgnoreIfNullConvention(new AlwaysIgnoreIfNullConvention()); BsonClassMap.RegisterConventions(conventions, t => true); ``` Thanks.