title: realm.xamarin throws error: The method 'Contains' is not supported. same for 'Any'
body: <p>i am writing a query which required 'WHERE IN' like clause in realm.xamarin linq query. below is the query i tried:</p>
  
  <pre><code>var IdsToMatch = observations.Select(x =&gt; x.Id)
  var results = from d in realm.All&lt;Observations&gt;() where IdsToMatch.Any(p =&gt; p == d.Id) select d;
  </code></pre>
  
  <p>also tried this with <code>Contains</code>:</p>
  
  <pre><code>var results = from d in realm.All&lt;Observations&gt;() where IdsToMatch.Contains(d.Id) select d;
  </code></pre>
  
  <p>but this throws error: </p>
  
  <pre><code>The method 'Contains' is not supported
  The method 'Any' is not supported
  </code></pre>
  
  <p>What is the solution for this?</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>here is the stack trace for the error:</p>
  
  <blockquote>
    <p>UNHANDLED EXCEPTION:
    06-07 15:04:55.097 I/MonoDroid(24526): System.NotSupportedException: The method 'Any' is not supported
    06-07 15:04:55.097 I/MonoDroid(24526):   at Realms.RealmResultsVisitor.VisitMethodCall (System.Linq.Expressions.MethodCallExpression m) [0x00596] in :0 
    06-07 15:04:55.097 I/MonoDroid(24526):   at Realms.ExpressionVisitor.Visit (System.Linq.Expressions.Expression exp) [0x000ec] in :0 
    06-07 15:04:55.097 I/MonoDroid(24526):   at Realms.RealmResultsVisitor.VisitMethodCall (System.Linq.Expressions.MethodCallExpression m) [0x0006a] in :0 
    06-07 15:04:55.097 I/MonoDroid(24526):   at Realms.ExpressionVisitor.Visit (System.Linq.Expressions.Expression exp) [0x000ec] in :0 
    06-07 15:04:55.097 I/MonoDroid(24526):   at Realms.RealmResults<code>1[T].CreateResultsHandle () [0x00037] in &lt;filename unknown&gt;:0 
    06-07 15:04:55.097 I/MonoDroid(24526):   at Realms.RealmResults</code>1[T].get_ResultsHandle () [0x0000d] in :0 
    06-07 15:04:55.097 I/MonoDroid(24526):   at Realms.RealmResults<code>1[T].GetEnumerator () [0x00000] in &lt;filename unknown&gt;:0 
    06-07 15:04:55.097 I/MonoDroid(24526):   at System.Collections.Generic.List</code>1[T]..ctor (IEnumerable<code>1 collection) [0x00073] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/collections/generic/list.cs:104 
    06-07 15:04:55.098 I/MonoDroid(24526):   at System.Linq.Enumerable.ToList[TSource] (IEnumerable</code>1 source) [0x00011] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:835 
    06-07 15:04:55.098 I/MonoDroid(24526):   at VHS.MobileApp.Mediq.DataAccess.ObservationDatabase+&lt;>c__DisplayClass13.b__8 () [0x00147] in d:\rwagh\mediq\Code\VHS.MobileApp.Mediq.DataAccess\ObservationDatabase.cs:65 
    06-07 15:04:55.098 I/MonoDroid(24526):   at System.Threading.Tasks.Task<code>1[TResult].InnerInvoke () [0x00012] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/threading/Tasks/Future.cs:686 
    06-07 15:04:55.098 I/MonoDroid(24526):   at System.Threading.Tasks.Task.Execute () [0x00016] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2523 
    06-07 15:04:55.098 I/MonoDroid(24526): --- End of stack trace from previous location where exception was thrown ---
    06-07 15:04:55.098 I/MonoDroid(24526):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
    06-07 15:04:55.098 I/MonoDroid(24526):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:201 
    06-07 15:04:55.098 I/MonoDroid(24526):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170 
    06-07 15:04:55.098 I/MonoDroid(24526):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142 
    06-07 15:04:55.098 I/MonoDroid(24526):   at System.Runtime.CompilerServices.TaskAwaiter</code>1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:372 </p>
  </blockquote>
  
  <p><strong>EDIT 2 :</strong></p>
  
  <pre><code>var IdsToMatch = observations.Select(x =&gt; x.Id)
  var results = from d in realm.All&lt;Observations&gt;() where IdsToMatch.Any(p =&gt; p == d.Id) select d;
  </code></pre>
  
  <p>tried: <code>var IdsToMatch = observations.Select(x =&gt; x.Id).AsQueryable()</code>
  as per <a href="https://github.com/realm/realm-dotnet/blob/7187390529201ba843cd105fc6e3e11acb0c6217/Realm.Shared/linq/RealmResultsVisitor.cs#L121" rel="nofollow">https://github.com/realm/realm-dotnet/blob/7187390529201ba843cd105fc6e3e11acb0c6217/Realm.Shared/linq/RealmResultsVisitor.cs#L121</a> which says </p>
  
  <pre><code>internal override Expression VisitMethodCall(MethodCallExpression m)
          {
              if (m.Method.DeclaringType == typeof(Queryable)) { ...
  </code></pre>
  
  <p>but that didn't work too.</p>