Permalink
Browse files

changed builder to assume that if the discriminator did not show up t…

…hen the class is the base class.
  • Loading branch information...
1 parent 62fc6e4 commit 8f7cde785e3d110de5aab71065cdee363d8417f7 @craiggwilson craiggwilson committed Jul 30, 2010
Showing with 12 additions and 1 deletion.
  1. +8 −0 examples/Simple/Main.cs
  2. +4 −1 source/MongoDB/Serialization/Builders/PolymorphicClassMapBuilder.cs
View
8 examples/Simple/Main.cs
@@ -81,6 +81,14 @@ public static void Main(string[] args)
collection.Save(circle);
collection.Save(sub);
+ var superclass = (from item in db.GetCollection<MyClass>("MyClass").Linq()
+ where item.Corners > 1
+ select item.Corners).ToList();
+
+ var subclass = (from item in db.GetCollection<SubClass>("MyClass").Linq()
+ where item.Ratio > 1
+ select item.Corners).ToList();
+
Console.WriteLine("Count by LINQ on typed collection: {0}", collection.Linq().Count(x => x.Corners > 1));
Console.WriteLine("Count by LINQ on typed collection2: {0}", db.GetCollection<SubClass>().Linq().Count(x => x.Corners > 1));
//Console.WriteLine("Count by LINQ on typed collection3: {0}", db.GetCollection<SubClass>().Count(new { Corners = Op.GreaterThan(1) }));
View
5 source/MongoDB/Serialization/Builders/PolymorphicClassMapBuilder.cs
@@ -38,7 +38,10 @@ public void AddProperty(string name, object value)
public object BuildObject()
{
if (_concreteEntityBuilder == null)
- throw new Exception("Discriminator did not show up.");
+ {
+ //we'll assume that this is the root class in the hierarchy.
+ _concreteEntityBuilder = new ConcreteClassMapBuilder(_classMap);
+ }
return _concreteEntityBuilder.BuildObject();
}

0 comments on commit 8f7cde7

Please sign in to comment.