From 0e2dfe640ff47ea5ff1e2562361cc1b252ac3dc4 Mon Sep 17 00:00:00 2001 From: Craig Wilson Date: Sat, 1 May 2010 14:26:14 -0500 Subject: [PATCH] fixed failing test --- .../IntegrationTests/Linq/MongoQueryTests.cs | 2 +- .../IntegrationTests/TestCollection_1.cs | 2 +- .../ClassMapPropertyDescriptorBase.cs | 20 ++++++++++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/source/MongoDB.Tests/IntegrationTests/Linq/MongoQueryTests.cs b/source/MongoDB.Tests/IntegrationTests/Linq/MongoQueryTests.cs index 59b55073..391917de 100644 --- a/source/MongoDB.Tests/IntegrationTests/Linq/MongoQueryTests.cs +++ b/source/MongoDB.Tests/IntegrationTests/Linq/MongoQueryTests.cs @@ -349,6 +349,6 @@ public void Complex_Addition() var people = Enumerable.ToList(collection.Linq().Where(x => x.Age + 23 < 50)); Assert.AreEqual(1, people.Count); - } + } } } \ No newline at end of file diff --git a/source/MongoDB.Tests/IntegrationTests/TestCollection_1.cs b/source/MongoDB.Tests/IntegrationTests/TestCollection_1.cs index 01599f28..830d4b89 100644 --- a/source/MongoDB.Tests/IntegrationTests/TestCollection_1.cs +++ b/source/MongoDB.Tests/IntegrationTests/TestCollection_1.cs @@ -276,7 +276,7 @@ private class DeletesEntity }; inserts.Insert(album); - var result = inserts.FindOne(new Document().Add("songs.title", "Deliveries After Dark")); + var result = inserts.FindOne(new Document().Add("Songs.Title", "Deliveries After Dark")); Assert.IsNotNull(result); Assert.AreEqual(album.Songs.Count, result.Songs.Count); diff --git a/source/MongoDB/Serialization/Descriptors/ClassMapPropertyDescriptorBase.cs b/source/MongoDB/Serialization/Descriptors/ClassMapPropertyDescriptorBase.cs index 4cc84d4c..f41cf9ed 100644 --- a/source/MongoDB/Serialization/Descriptors/ClassMapPropertyDescriptorBase.cs +++ b/source/MongoDB/Serialization/Descriptors/ClassMapPropertyDescriptorBase.cs @@ -81,14 +81,20 @@ protected PersistentMemberMap GetMemberMapFromMemberName(string name) var parts = name.Split('.'); memberMap = ClassMap.GetMemberMapFromMemberName(parts[0]); + if (memberMap == null) + return null; + var currentType = memberMap.MemberReturnType; for (int i = 1; i < parts.Length && memberMap != null; i++) { - if (IsNumeric(parts[i])) //we are an array indexer + var collectionMemberMap = memberMap as CollectionMemberMap; + if (collectionMemberMap != null) { currentType = ((CollectionMemberMap)memberMap).ElementType; - continue; + if (IsNumeric(parts[i])) //we are an array indexer + continue; } + var classMap = _mappingStore.GetClassMap(currentType); memberMap = classMap.GetMemberMapFromAlias(parts[i]); if (memberMap != null) @@ -136,11 +142,15 @@ protected string GetAliasFromMemberName(string name) { if(memberMap != null) { - if (IsNumeric(parts[i])) //we are an array indexer + var collectionMemberMap = memberMap as CollectionMemberMap; + if (collectionMemberMap != null) { currentType = ((CollectionMemberMap)memberMap).ElementType; - sb.Append(".").Append(parts[i]); - continue; + if (IsNumeric(parts[i])) //we are an array indexer + { + sb.Append(".").Append(parts[i]); + continue; + } } var classMap = _mappingStore.GetClassMap(currentType);