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

Can't query URI types on scheme/host/path etc

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • BSON, Linq
    • None

    Description

      With the URI type is serialized to string, you can only do direct comparison (equal/not equal) whereas in C#, the type has various more properties like scheme, host, path etc. Because of this, you can't do many useful queries against this type, making it kinda useless to even support serialization of the Uri type.

      For example, take the following class:

      class ExampleClass
      {
          public string Id { get; set; }
          public Uri WebsiteUri { get; set; }
      }
      

      I can't query it like:

      myCollection.AsQueryable().Where(e => e.WebsiteUri.Host == "somedomain.com");
      

      Because

      InvalidOperationException: {document}{WebsiteUri}.Host is not supported.

      I can only do this:

      myCollection.AsQueryable().Where(e => e.WebsiteUri == new Uri("http://somedomain.com/some-page"));
      

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            james@turnersoftware.com.au James Turner
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: