Uploaded image for project: 'Realm .NET SDK'
  1. Realm .NET SDK
  2. RNET-212

.ToArray(), foreach, and .ForEach() use .Select() internally, which has yet to be supported

      <!--- Questions: If you have questions about how to use Realm, please ask on -->
      <!--- StackOverflow: http://stackoverflow.com/questions/ask?tags=realm -->
      <!--- We monitor the realm tag. -->

      <!--- Feature Request: Just fill in the first two sections below. -->

      <!--- Bugs: To help you as fast as possible with an issue please describe your issue -->
      <!--- and the steps you have taken to reproduce it in as much detail as possible. -->

      <Unable to render embedded object: File (--- Thanks for helping us help you) not found. -->

      Goals

      Attempting to iterate through an IEnumerable collection of RealmObjects and perform some action.
      <!--- What are you trying to achieve? -->

      Expected Results

      For this to work.
      <!--- What did you expect to happen? -->

      Actual Results

      ERROR: Select not supported
      

      The stack trace leads me to believe that the two foreach statements are both calling ToArray under the covers, which triggers the error.

      I've been following the supported LINQ documentation like gospel, so I'm aware of what is and is not supported. Is it as simple as doing any of these operations on an IEnumerable collection that contains RealmObjects just does not work?
      <!--- What happened instead? -->
      <!--- e.g. the stack trace of a crash -->

      Steps to Reproduce

      1. Resolve a ThreadSafeReference to an IQueryable collection containing RealmObjects
      2. Using query syntax, run a select statement to filter the object to a single attribute (another collection)
      3. Order result of 2 by count and find firstOrDefault()
      4. Try to iterate through collection.
        <!--- What are steps we can follow to reproduce this issue? -->

      Code Sample

      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
      var categoryAttributes= Realm.GetInstance(Configuration).ResolveReference(threadSafeFilteredProducts)
      var attributeGroupWithMaxAttributes = from ca in categoryAttributes orderby ca.Count() select ca.FirstOrDefault();
      
      //Error, Select not supported on all of these
      var testArr = attributeGroupWithMaxAttributes.ToArray();
      foreach (CategoryAttribute a in attributeGroupWithMaxAttributes);
      attributeGroupWithMaxAttributes?.ToList().ForEach(...);
      

      <!--- Please provide a code sample or test case that highlights the issue. -->
      <!--- If relevant, include your model definitions. -->
      <!--- For larger code samples, links to external gists/repositories are preferred. -->
      <!--- Alternatively, you can share information confidentially via email at help@realm.io. -->
      <Unable to render embedded object: File (--- Full projects that we can compile and run ourselves are ideal) not found. -->

      Version of Realm and Tooling

      • Realm Object Server Version: ? (you can see this as well in Studio once connected to a Realm instance) 4.2
      • Flavor:
        • [ X ] Realm Cloud
        • [ ] Self-Hosted
      • Server OS & Version: ? (e.g. CentOS 6) Windows 10 version should not matter
      • Client SDK Version: ? 4.2
      • Client OS & Version: ? Windows 10

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: