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

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.4.3
    • Component/s: API, LINQ
    • None
    • Environment:
      Windows 10 x64
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      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
            Reporter:
            Lewis Gill
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: