Theoretically, it is supporting dynamic type. However, (practice) dynamic type itself conflict with BSON de-serialization,
i.e.
public class TestClass2<T>
{
public MongoDB.Bson.ObjectId Id { get; set; }
public T data { get; set; }
}
1. Inserting with TestClass2<int> instance typed as dynamic c# variable, it will smoothly insert into mongodb as well as retrieve.
2. Now when you try to insert TestClass2<string> dynamic type, save will work but won't retrieve because of type mismatch and will fail.
Exception message: "An error occurred while deserializing the data property of class LearningPad.TestClass2`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: Input string was not in a correct format." @MongoConnection.cs Line 442
3. Only overcome is to use distinguish collections for each possible generic type (by writing some custom function that evaluate collection name runtime) but that is impracticable as you can't query them at once.
4. I use object wrapper (that works fine) with generic promotion of fields in wrapper to make them queryable and indexable. So far that is the best solution I'm into.
Any more idea!
Cheers!
N.