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

Support downcasting object in LINQ queries

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 1.8.3
    • Fix Version/s: 1.9
    • Component/s: None
    • Labels:
      None

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              rstam Robert Stam
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: