Exemple #1
0
        //--------------------------------------------------------------------------------------------------------------------------------------------------

        #region Private methods
        //--------------------------------------------------------------------------------------------------------------------------------------------------
        private Expression JoinMethod(MethodCallExpression expression)
        {
            // first argument is another join or method call
            if (expression.Arguments[0] is MethodCallExpression)
            {
                VisitMethodCall((MethodCallExpression)expression.Arguments[0]);
            }

            var joinFromType = ((LambdaExpression)((UnaryExpression)expression.Arguments[4]).Operand).Parameters[0].Type;

            // from type if generic, possbily another join
            if (joinFromType.IsGenericType)
            {
                joinFromType = joinFromType.GenericTypeArguments[1];
            }
            var joinToType = ((LambdaExpression)((UnaryExpression)expression.Arguments[4]).Operand).Parameters[1].Type;

            EntityTableCacheHelper.ToEntityTable(joinFromType);
            var joinToTable = EntityTableCacheHelper.ToEntityTable(joinToType);

            var primaryJoinColumn   = _serverWriter.GetPropertyNameWithIdentifierFromExpression(expression.Arguments[2]);
            var secondaryJoinColumn = _serverWriter.GetPropertyNameWithIdentifierFromExpression(expression.Arguments[3]);

            _serverWriter.WriteJoin(joinToTable.Name, joinToTable.Identifier, primaryJoinColumn, secondaryJoinColumn);

            return(expression);
        }