Cannot perform LINQ complex object search in Entity Framework <p>I have entities in the DB which each contain a list of key value pairs as metadata. I want to return a list of object by matching on specified items in the metadata.</p> <p>Ie if objects can have metadata of KeyOne, KeyTwo and KeyThree, I want to be able to say "Bring me back all objects where KeyOne contains "abc" and KeyThree contains "de"</p> <p>This is my C# query</p> <pre><code> var objects = repository.GetObjects().Where(t =&gt; request.SearchFilters.All(f =&gt; t.ObjectChild.Any(tt =&gt; tt.MetaDataPairs.Any(md =&gt; md.Key.ToLower() == f.Key.ToLower() &amp;&amp; md.Value.ToLower().Contains(f.Value.ToLower()) ) ) ) ).ToList(); </code></pre> <p>and this is my request class</p> <pre><code>[DataContract] public class FindObjectRequest { [DataMember] public IDictionary&lt;string, string&gt; SearchFilters { get; set; } } </code></pre> <p>And lastly my Metadata POCO</p> <pre><code>[Table("MetaDataPair")] public class DbMetaDataPair : IEntityComparable&lt;DbMetaDataPair&gt; { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long Id { get; set; } [Required] public string Key { get; set; } public string Value { get; set; } } </code></pre> <p>The error I get is</p> <blockquote> <p>Error was Unable to create a constant value of type 'System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'. Only primitive types or enumeration types are supported in this context.</p> </blockquote>