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

Checking for the existence of an index is very verbose

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.0, 2.1
    • Component/s: API
    • Labels:
      None

      This is a request for a 'HasIndex(string indexName)' or 'ContainsIndex(string indexName)' helper.

      Unless I'm missing something, to find out if an index exists on a collection, one must:

      var query = await myCollection.Indexes.ListAsync();
      var bsonIndexes = await query.ToListAsync();
      var indexNames = bsonIndexes .Select(i => i.Values); // or some variation
      return indexNames.Contains("blah");

            Assignee:
            Unassigned Unassigned
            Reporter:
            nick@innsenroute.com Nick Judson
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: