internal virtual SqlExpression VisitUserRow(SqlUserRow row) { return row; }
internal override SqlExpression VisitUserRow(SqlUserRow row) { if (!isDebugMode) { throw Error.InvalidFormatNode("UserRow"); } return row; }
internal override SqlExpression VisitUserRow(SqlUserRow row) { return new SqlUserRow(row.RowType, row.SqlType, (SqlUserQuery)this.Visit(row.Query), row.SourceExpression); }
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; }
/// <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; }
internal override SqlExpression VisitUserRow(SqlUserRow row) { return(new SqlUserRow(row.RowType, row.SqlType, (SqlUserQuery)this.Visit(row.Query), row.SourceExpression)); }