Allow projections after OfType()

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Done
    • Priority: Minor - P4
    • 1.5
    • Affects Version/s: 1.4.2
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Projections are deliberately not allowed on an expression using OfType().

      The following test illustrates the desired behaviour:

              public abstract class Base
              {
                  public string A { get; set; }
              }
      
              public class T1 : Base
              {
                  public string B { get; set; }
              }
      
      
              [Test]
              public void ProjectAfterOfTypeTest()
              {
                  var server = MongoServer.Create(mongo.WriterConnectionString);
                  var db = server.GetDatabase(mongo.Database);
                  var collection = db.GetCollection<Base>("ProjectTest");
      
                  var t1 = new T1 { A = "T1.A", B = "T1.B" };
              
                  collection.Insert(t1);
              
                  var query = from t in collection.AsQueryable().OfType<T1>() select t.B;
                  var results = query.ToList();
                  Assert.That(results.Count, Is.EqualTo(1));
                  Assert.That(results[0], Is.EqualTo("T1.B"));
              }
      

            Assignee:
            Craig Wilson
            Reporter:
            Andy Clapham
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: