Support LINQ Cast operator.

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Works as Designed
    • Priority: Minor - P4
    • None
    • Affects Version/s: 1.7
    • Component/s: LINQ
    • None
    • 🔵 Done
    • 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

      In LINQ2SQL I could wrote:

      Unable to find source-code formatter for language: cs. 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
      public static int? GetIDByHash(this IQueryable<Picture> source, byte[] hash)
      {
      	return
      		source
      			.Where(p_ => p_.Hash == hash)
      			.Select(p_ => (int?)p_.ID)
      			.SingleOrDefault();
      }
      

      But in LINQ in MongoDB i can't do this. I have to do so:

      Unable to find source-code formatter for language: cs. 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
      public static int? GetIDByHash(this IQueryable<Picture> source, byte[] hash)
      {
      	var pic = source.SingleOrDefault(p => p.Hash == hash);
      	return pic != null ? pic.ID : default(int?);
      }
      

      This saddens me.

      The same issue appears with the Cast<int?>() operator.

            Assignee:
            Robert Stam (Inactive)
            Reporter:
            Evheny Nemov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: