Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Commit

Permalink
began working on reworking the serialization to accomodate inheritanc…
Browse files Browse the repository at this point in the history
…e needs.
  • Loading branch information
craiggwilson committed Aug 9, 2010
1 parent 23b6289 commit 98e7d4b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions source/MongoDB/MongoCollection_1.cs
Expand Up @@ -7,6 +7,7 @@
using MongoDB.Protocol;
using MongoDB.Results;
using MongoDB.Util;
using MongoDB.Configuration.Mapping.Model;

namespace MongoDB
{
Expand Down Expand Up @@ -602,5 +603,25 @@ private object EnsureUpdateDocument(object document)

return document;
}

private Document ConvertObjectToDocument(object document)
{
Document doc = document as Document;
if (doc != null)
return doc;

if (document is T)
{
var classMap = _configuration.MappingStore.GetClassMap(typeof(T));
foreach (PersistentMemberMap memberMap in classMap)
{
doc[memberMap.MemberName] = memberMap.GetValue(document);
}
}
else //anonymous type...
{

}
}
}
}
2 changes: 1 addition & 1 deletion source/MongoDB/Protocol/QueryMessage.cs
Expand Up @@ -17,7 +17,7 @@ namespace MongoDB.Protocol
/// [ BSON returnFieldSelector; ] // OPTIONAL : selector indicating the fields to return. See below for details.
/// }
/// </remarks>
internal class QueryMessage : RequestMessageBase
internal class QueryMessage<T> : RequestMessageBase
{
/// <summary>
/// Initializes a new instance of the <see cref="QueryMessage"/> class.
Expand Down
Expand Up @@ -35,7 +35,7 @@ public IEnumerable<string> GetMongoPropertyNames(object instance)
if (_classMap.HasId)
yield return _classMap.IdMap.Alias;

if (_classMap.IsPolymorphic && _classMap.HasDiscriminator)
if (_classMap.IsSubClass)
yield return _classMap.DiscriminatorAlias;

foreach (var memberMap in _classMap.MemberMaps)
Expand Down

0 comments on commit 98e7d4b

Please sign in to comment.