-
Type: Bug
-
Resolution: Done
-
Priority: Critical - P2
-
Affects Version/s: 1.4
-
Component/s: None
-
None
Got abstract BaseClass and DerivedClass in "collection1"
Mapping:
//BaseClass BsonClassMap.RegisterClassMap<BaseClass>(cm => { cm.AutoMap(); cm.MapIdProperty(x => x.Id); cm.SetIsRootClass(true); cm.GetMemberMap(c => c.Properties) .SetSerializationOptions(DictionarySerializationOptions.ArrayOfDocuments); }); BsonClassMap.RegisterClassMap<DerivedClass>();
Query:
var s1 = db.GetCollection("collection1").AsQueryable<DerivedClass>().Where(x => x.Id == "some").Single(); - don't work var s2 = db.GetCollection("collection1").AsQueryable<BaseClass>().Where(x => x.Id == "some").Single(); - work var s3 = db.GetCollection("collection1").AsQueryable<DerivedClass>().Where(x => x.SomeLogicalField).Single(); - work var s4 = db.GetCollection("collection1").AsQueryable<DerivedClass>().Where(x => x.SomeIntegerField > 666).Single(); - work
Exception: NullReferenceException "Object reference not set to an instance of an object"
Stack:
at MongoDB.Bson.Serialization.BsonClassMapSerializer.GetMemberSerializationInfo(String memberName) in C:\work\10gen\mongodb\mongo-csharp-driver\Bson\Serialization\BsonClassMapSerializer.cs:line 253
at MongoDB.Driver.Linq.SelectQuery.GetSerializationInfoMember(IBsonSerializer serializer, MemberExpression memberExpression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 962
at MongoDB.Driver.Linq.SelectQuery.GetSerializationInfo(IBsonSerializer serializer, Expression expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 888
at MongoDB.Driver.Linq.SelectQuery.GetSerializationInfo(Expression expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 880
at MongoDB.Driver.Linq.SelectQuery.BuildComparisonQuery(BinaryExpression binaryExpression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 433
at MongoDB.Driver.Linq.SelectQuery.BuildQuery(Expression expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 768
at MongoDB.Driver.Linq.SelectQuery.BuildQuery() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 113
at MongoDB.Driver.Linq.SelectQuery.Execute() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\Translators\SelectQuery.cs:line 122
at MongoDB.Driver.Linq.MongoQueryProvider.Execute(Expression expression) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\MongoQueryProvider.cs:line 147
at MongoDB.Driver.Linq.MongoQueryable`1.GetEnumerator() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Linq\MongoQueryable.cs:line 81
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at DatabaseMappingTest.Program.Main() in D:\Projects\Support Projects\TestDBSchema\DatabaseMappingTest\Program.cs:line 3380
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
- duplicates
-
CSHARP-418 NullReferenceException in LINQ query when querying against inherited field or property
- Closed