Пример #1
0
        private MethodCallExpression CreateSelectExpression(Expression source)
        {
            if (_rootNavigationItem.HasNavigationItems())
            {
                return((MethodCallExpression)source);
            }

            if (_rootNavigationItem.AllSelected)
            {
                return((MethodCallExpression)source);
            }

            ParameterExpression parameter = _joinBuilder.Visitor.Parameter;
            IReadOnlyList <OeStructuralSelectItem> structuralItems = _rootNavigationItem.GetStructuralItemsWithNotSelected();
            var expressions = new Expression[structuralItems.Count];

            for (int i = 0; i < expressions.Length; i++)
            {
                if (structuralItems[i].EdmProperty is ComputeProperty computeProperty)
                {
                    expressions[i] = computeProperty.Expression;
                }
                else
                {
                    PropertyInfo clrProperty = parameter.Type.GetPropertyIgnoreCase(structuralItems[i].EdmProperty);
                    expressions[i] = Expression.MakeMemberAccess(parameter, clrProperty);
                }
            }
            NewExpression newTupleExpression = OeExpressionHelper.CreateTupleExpression(expressions);

            LambdaExpression lambda           = Expression.Lambda(newTupleExpression, parameter);
            MethodInfo       selectMethodInfo = OeMethodInfoHelper.GetSelectMethodInfo(parameter.Type, newTupleExpression.Type);

            return(Expression.Call(selectMethodInfo, source, lambda));
        }
Пример #2
0
        private static OePropertyAccessor[] GetAccessors(Type clrEntityType, OeNavigationSelectItem navigationItem)
        {
            ParameterExpression parameter;
            UnaryExpression     typedAccessorParameter;
            IReadOnlyList <MemberExpression> propertyExpressions;

            if (navigationItem.AllSelected)
            {
                if (navigationItem.Parent != null && navigationItem.NavigationSelectItem is ExpandedCountSelectItem)
                {
                    parameter = Expression.Parameter(typeof(Object));
                    typedAccessorParameter = Expression.Convert(parameter, clrEntityType);
                    propertyExpressions    = OeExpressionHelper.GetPropertyExpressions(typedAccessorParameter);
                    return(new[] { OePropertyAccessor.CreatePropertyAccessor(OeEdmClrHelper.CountProperty, propertyExpressions[0], parameter, false) });
                }
                else
                {
                    return(OePropertyAccessor.CreateFromType(clrEntityType, navigationItem.EntitySet));
                }
            }

            parameter = Expression.Parameter(typeof(Object));
            typedAccessorParameter = Expression.Convert(parameter, clrEntityType);
            propertyExpressions    = OeExpressionHelper.GetPropertyExpressions(typedAccessorParameter);

            IReadOnlyList <OeStructuralSelectItem> structuralItems = navigationItem.GetStructuralItemsWithNotSelected();
            var accessors = new OePropertyAccessor[structuralItems.Count];

            for (int i = 0; i < structuralItems.Count; i++)
            {
                accessors[i] = OePropertyAccessor.CreatePropertyAccessor(structuralItems[i].EdmProperty, propertyExpressions[i], parameter, structuralItems[i].NotSelected);
            }

            return(accessors);
        }
Пример #3
0
        private static OePropertyAccessor[] GetAccessors(Type clrEntityType, OeNavigationSelectItem navigationItem)
        {
            if (navigationItem.StructuralItems.Count == 0)
            {
                return(OePropertyAccessor.CreateFromType(clrEntityType, navigationItem.EntitySet));
            }

            IReadOnlyList <OeStructuralSelectItem> structuralItems = navigationItem.GetStructuralItemsWithNotSelected();
            var accessors = new OePropertyAccessor[structuralItems.Count];

            ParameterExpression parameter = Expression.Parameter(typeof(Object));
            UnaryExpression     typedAccessorParameter           = Expression.Convert(parameter, clrEntityType);
            IReadOnlyList <MemberExpression> propertyExpressions = OeExpressionHelper.GetPropertyExpressions(typedAccessorParameter);

            for (int i = 0; i < structuralItems.Count; i++)
            {
                accessors[i] = OePropertyAccessor.CreatePropertyAccessor(structuralItems[i].EdmProperty, propertyExpressions[i], parameter, structuralItems[i].NotSelected);
            }

            return(accessors);
        }