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

Support Where(c => c.GetType() == type) in LINQ

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.3
    • Component/s: API, Linq
    • Labels:
      None
    • Environment:
      Windows 10 x64

      I think this is the same issue as CSHARP-1714.

      However, I cannot use the "is" clause workaround because I have a set of Type variables that I'm using to build up a dynamic LINQ query, so I can't use the "is" clause, which requires a constant expression.

      Is there now a way to make the following work with MongoDB?

      Type type1 = typeof(MyObject1);
      Type type2 = typeof(MyObject2);
      query.Where( c => c.GetType() == type1 || c => c.GetType() == type2);

      I've manually verified that using an "is" clause does work on the same query.

            Assignee:
            Unassigned Unassigned
            Reporter:
            lewisrg Lewis Gill
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: