Esempio n. 1
0
            protected override Expression VisitMember(MemberExpression node)
            {
                if (!_translateToSql)
                {
                    var sqlExpression = _selectExpression.GetProjectionForMemberInfo(node.Member);
                    if (sqlExpression != null)
                    {
                        return(BindSqlToValueBuffer(sqlExpression, node.Type));
                    }

                    if (node.Member.Name == KeyName &&
                        node.Expression.TryGetReferencedQuerySource() == _groupQuerySource)
                    {
                        var querySourceFinder = new QuerySourceFindingExpressionVisitor();
                        querySourceFinder.Visit(_keySelector);

                        var currentParameter = _queryModelVisitor.CurrentParameter;

                        foreach (var querySource in querySourceFinder.QuerySources)
                        {
                            _queryModelVisitor.QueryCompilationContext.AddOrUpdateMapping(
                                querySource,
                                currentParameter);
                        }

                        return(_projectionExpressionVisitor.Visit(_keySelector));
                    }
                }

                return(base.VisitMember(node));
            }
            protected override Expression VisitMember(MemberExpression memberExpression)
            {
                if (!_translateToSql)
                {
                    // For composite Key case, projection member info will be already populated
                    var sqlExpression = _selectExpression.GetProjectionForMemberInfo(memberExpression.Member);
                    if (sqlExpression != null)
                    {
                        return(BindSqlToValueBuffer(sqlExpression, memberExpression.Type));
                    }

                    if (memberExpression.Member.Name == KeyName &&
                        memberExpression.Expression.TryGetReferencedQuerySource() == _groupQuerySource)
                    {
                        var querySourceFinder = new QuerySourceFindingExpressionVisitor();
                        querySourceFinder.Visit(_keySelector);

                        var currentParameter = _queryModelVisitor.CurrentParameter;

                        foreach (var querySource in querySourceFinder.QuerySources)
                        {
                            _queryModelVisitor.QueryCompilationContext.AddOrUpdateMapping(
                                querySource,
                                currentParameter);
                        }

                        sqlExpression = _projectionExpressionVisitor.Visit(_keySelector);
                        _sqlMapping[memberExpression] = sqlExpression;
                        return(sqlExpression);
                    }
                }

                return(base.VisitMember(memberExpression));
            }