Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-900

Support downcasting object in LINQ queries

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.9
    • Affects Version/s: 1.8.3
    • Component/s: None
    • None

      It would be nice if given a class like:

      public class C
      {
          public int _id;
          public object F;
          public object[] L;
      }
      

      One could write LINQ queries like:

      collection.AsQueryable<C>().Where(c => (int)c.F > 10);
      // or
      collection.AsQueryable<C>().Where(c => c.L.Any(o => (int)o > 10));
      

      Normally we deduce the serialized form of the value from the type information of the field, but in this case we would have to deduce the desired type from the cast used in the query.

      Not sure what all the ramifications of this feature are... it's possible that there is more to it than initially meets the eye and this might not turn out to be easily doable. So the first step is to properly research the feasability of this feature.

            Assignee:
            Unassigned Unassigned
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: