private IEnumerable<string> buildBinary(BinaryExpression[] binaryExpressions, NpgsqlCommand command) { if (!binaryExpressions.Any()) { yield break; } var dictionary = new Dictionary<string, object>(); // Are we querying directly againt the elements as you would for primitive types? if (binaryExpressions.All(x => x.Left is QuerySourceReferenceExpression && x.Right is ConstantExpression)) { if (binaryExpressions.Any(x => x.NodeType != ExpressionType.Equal)) { throw new NotSupportedException("Only the equality operator is supported on Collection.Any(x => x) searches directly against the element"); } var values = binaryExpressions.Select(x => x.Right.Value()).ToArray(); if (_members.Length == 1) { dictionary.Add(_members.Single().Name, values); } else { throw new NotSupportedException(); } } else { var search = new Dictionary<string, object>(); binaryExpressions.Each(x => gatherSearch(x, search)); if (_members.Length == 1) { dictionary.Add(_members.Single().Name, new[] { search }); } else { throw new NotImplementedException(); } } var json = _serializer.ToCleanJson(dictionary); var param = command.AddParameter(json); param.NpgsqlDbType = NpgsqlDbType.Jsonb; yield return $"d.data @> :{param.ParameterName}"; }