예제 #1
0
        private static ODataSelectOneQueryOperation CreateGetOneQuery(Queue <OperationTuple> operations, OperationTuple item, LambdaExpression projectionExpression, Type projectionType, IDictionary <string, PropertyDetails> projectedProperties)
        {
            var whereClause    = item.Expression as UnaryExpression;
            var whereOperand   = whereClause.Operand as LambdaExpression;
            var wherePredicate = whereOperand.Body as BinaryExpression;
            var value          = (wherePredicate.Right as ConstantExpression).Value.ToString();
            var operandType    = whereOperand.Type.GetGenericArguments().ElementAt(0);

            return(new ODataSelectOneQueryOperation
            {
                OfType = operandType,
                Keys = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase)
                {
                    { "key", value }
                },
                ProjectionExpression = projectionExpression,
                ProjectedType = projectionType,
                ProjectedProperties = projectedProperties,
            });
        }
        private static ODataSelectOneQueryOperation CreateGetOneQuery(Queue<OperationTuple> operations, OperationTuple item, LambdaExpression projectionExpression, Type projectionType, IDictionary<string, PropertyDetails> projectedProperties)
        {
            var whereClause = item.Expression as UnaryExpression;
            var whereOperand = whereClause.Operand as LambdaExpression;
            var wherePredicate = whereOperand.Body as BinaryExpression;
            var value = (wherePredicate.Right as ConstantExpression).Value.ToString();
            var operandType = whereOperand.Type.GetGenericArguments().ElementAt(0);

            return new ODataSelectOneQueryOperation
            {
                OfType = operandType,
                Keys = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) { { "key", value } },
                ProjectionExpression = projectionExpression,
                ProjectedType = projectionType,
                ProjectedProperties = projectedProperties,
            };
        }