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

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

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: BSON, Linq
    • None

      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:

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      class ExampleClass
      {
          public string Id { get; set; }
          public Uri WebsiteUri { get; set; }
      }
      

      I can't query it like:

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      myCollection.AsQueryable().Where(e => e.WebsiteUri.Host == "somedomain.com");
      

      Because

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

      I can only do this:

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      myCollection.AsQueryable().Where(e => e.WebsiteUri == new Uri("http://somedomain.com/some-page"));
      

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

              Created:
              Updated:
              Resolved: