예제 #1
0
 internal virtual SqlExpression VisitUserRow(SqlUserRow row) {
     return row;
 }
예제 #2
0
 internal override SqlExpression VisitUserRow(SqlUserRow row) {
     if (!isDebugMode) {
         throw Error.InvalidFormatNode("UserRow");
     }
     return row;
 }
예제 #3
0
 internal override SqlExpression VisitUserRow(SqlUserRow row) {
     return new SqlUserRow(row.RowType, row.SqlType, (SqlUserQuery)this.Visit(row.Query), row.SourceExpression);
 }
예제 #4
0
        private SqlUserQuery VisitUserQuery(string query, Expression[] arguments, Type resultType) {
            SqlExpression[] args = new SqlExpression[arguments.Length];
            for (int i = 0, n = args.Length; i < n; i++) {
                args[i] = this.VisitExpression(arguments[i]);
            }
            SqlUserQuery suq = new SqlUserQuery(query, null, args, this.dominatingExpression);
            if (resultType != typeof(void)) {
                Type elementType = TypeSystem.GetElementType(resultType);
                MetaType mType = this.services.Model.GetMetaType(elementType);

                // if the element type is a simple type (int, bool, etc.) we create
                // a single column binding
                if (TypeSystem.IsSimpleType(elementType)) {
                    SqlUserColumn col = new SqlUserColumn(elementType, typeProvider.From(elementType), suq, "", false, this.dominatingExpression);
                    suq.Columns.Add(col);
                    suq.Projection = col;
                }
                else {
                    // ... otherwise we generate a default projection
                    SqlUserRow rowExp = new SqlUserRow(mType.InheritanceRoot, this.typeProvider.GetApplicationType((int)ConverterSpecialTypes.Row), suq, this.dominatingExpression);
                    suq.Projection = this.translator.BuildProjection(rowExp, mType, this.allowDeferred, null, this.dominatingExpression);
                }
            }
            return suq;
        }
예제 #5
0
        /// <summary>
        /// Translate a call to a stored procedure
        /// </summary>             
        private SqlNode TranslateStoredProcedureCall(MethodCallExpression mce, MetaFunction function) {
            if (!this.outerNode) {
                throw Error.SprocsCannotBeComposed();
            }

            // translate method call into sql function call
            List<SqlExpression> sqlParams = GetFunctionParameters(mce, function);

            SqlStoredProcedureCall spc = new SqlStoredProcedureCall(function, null, sqlParams, mce);

            Type returnType = mce.Method.ReturnType;
            if (returnType.IsGenericType &&
                (returnType.GetGenericTypeDefinition() == typeof(IEnumerable<>) ||
                returnType.GetGenericTypeDefinition() == typeof(ISingleResult<>))) {

                // Since this is a single rowset returning sproc, we use the one
                // and only root metatype.
                MetaType rowType = function.ResultRowTypes[0].InheritanceRoot;
                
                SqlUserRow rowExp = new SqlUserRow(rowType, this.typeProvider.GetApplicationType((int)ConverterSpecialTypes.Row), spc, mce);
                spc.Projection = this.translator.BuildProjection(rowExp, rowType, this.allowDeferred, null, mce);
            }
            else if (!(
                typeof(IMultipleResults).IsAssignableFrom(returnType)
                || returnType == typeof(int)
                || returnType == typeof(int?)
                )) {
                throw Error.InvalidReturnFromSproc(returnType);
            }

            return spc;
        }
예제 #6
0
 internal virtual SqlExpression VisitUserRow(SqlUserRow row) {
     return row;
 }
 internal override SqlExpression VisitUserRow(SqlUserRow row)
 {
     return(new SqlUserRow(row.RowType, row.SqlType, (SqlUserQuery)this.Visit(row.Query), row.SourceExpression));
 }