本文整理汇总了C#中System.Linq.Expressions.BinaryExpression.All方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryExpression.All方法的具体用法?C# BinaryExpression.All怎么用?C# BinaryExpression.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.BinaryExpression
的用法示例。
在下文中一共展示了BinaryExpression.All方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buildBinary
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}";
}