internal SqlUserColumn(Type clrType, ProviderType sqlType, SqlUserQuery query, string name, bool isRequired, Expression source) : base(SqlNodeType.UserColumn, clrType, sqlType, source) { this.Query = query; this.name = name; this.isRequired = isRequired; }
internal virtual SqlUserQuery VisitUserQuery(SqlUserQuery suq) { for (int i = 0, n = suq.Arguments.Count; i < n; i++) { suq.Arguments[i] = this.VisitExpression(suq.Arguments[i]); } suq.Projection = this.VisitExpression(suq.Projection); for (int i = 0, n = suq.Columns.Count; i < n; i++) { suq.Columns[i] = (SqlUserColumn) this.Visit(suq.Columns[i]); } return suq; }
private IObjectReaderFactory GetDefaultFactory(MetaType rowType) { if(rowType == null) { throw Error.ArgumentNull("rowType"); } SqlNodeAnnotations annotations = new SqlNodeAnnotations(); Expression tmp = Expression.Constant(null); SqlUserQuery suq = new SqlUserQuery(string.Empty, null, null, tmp); if(TypeSystem.IsSimpleType(rowType.Type)) { // if the element type is a simple type (int, bool, etc.) we create // a single column binding SqlUserColumn col = new SqlUserColumn(rowType.Type, _typeProvider.From(rowType.Type), suq, "", false, suq.SourceExpression); suq.Columns.Add(col); suq.Projection = col; } else { // ... otherwise we generate a default projection SqlUserRow rowExp = new SqlUserRow(rowType.InheritanceRoot, _typeProvider.GetApplicationType((int)ConverterSpecialTypes.Row), suq, tmp); suq.Projection = _translator.BuildProjection(rowExp, rowType, true, null, tmp); } Type resultType = TypeSystem.GetSequenceType(rowType.Type); QueryInfo[] qis = this.BuildQuery(ResultShape.Sequence, resultType, suq, null, annotations); return this.GetReaderFactory(qis[qis.Length - 1].Query, rowType.Type); }
internal override SqlUserQuery VisitUserQuery(SqlUserQuery suq) { if(suq.Arguments.Count > 0) { // compute all the arg values... StringBuilder savesb = _commandStringBuilder; _commandStringBuilder = new StringBuilder(); object[] args = new object[suq.Arguments.Count]; for(int i = 0, n = args.Length; i < n; i++) { this.Visit(suq.Arguments[i]); args[i] = _commandStringBuilder.ToString(); _commandStringBuilder.Length = 0; } _commandStringBuilder = savesb; // append query with args... _commandStringBuilder.Append(String.Format(CultureInfo.InvariantCulture, suq.QueryText, args)); } else { _commandStringBuilder.Append(suq.QueryText); } return suq; }
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, _dominatingExpression); if(resultType != typeof(void)) { Type elementType = TypeSystem.GetElementType(resultType); MetaType mType = _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, _dominatingExpression); suq.Columns.Add(col); suq.Projection = col; } else { // ... otherwise we generate a default projection SqlUserRow rowExp = new SqlUserRow(mType.InheritanceRoot, _typeProvider.GetApplicationType((int)ConverterSpecialTypes.Row), suq, _dominatingExpression); suq.Projection = _translator.BuildProjection(rowExp, mType, _allowDeferred, null, _dominatingExpression); } } return suq; }
internal SqlUserRow(MetaType rowType, ProviderType sqlType, SqlUserQuery query, Expression source) : base(SqlNodeType.UserRow, rowType.Type, sqlType, source) { this.Query = query; this.rowType = rowType; }
internal override SqlUserQuery VisitUserQuery(SqlUserQuery suq) { List<SqlExpression> args = new List<SqlExpression>(suq.Arguments.Count); foreach(SqlExpression expr in suq.Arguments) { args.Add(this.VisitExpression(expr)); } SqlExpression projection = this.VisitExpression(suq.Projection); SqlUserQuery n = new SqlUserQuery(suq.QueryText, projection, args, suq.SourceExpression); this.nodeMap[suq] = n; foreach(SqlUserColumn suc in suq.Columns) { SqlUserColumn dupSuc = new SqlUserColumn(suc.ClrType, suc.SqlType, suc.Query, suc.Name, suc.IsRequired, suc.SourceExpression); this.nodeMap[suc] = dupSuc; n.Columns.Add(dupSuc); } return n; }
internal SqlUserColumn(Type clrType, ProviderType sqlType, SqlUserQuery query, string name, bool isRequired, Expression source) : base(SqlNodeType.UserColumn, clrType, sqlType, source) { this.Query = query; this.name = name; this.isRequired = isRequired; }
internal override SqlUserQuery VisitUserQuery(SqlUserQuery suq) { bool saveTop = this.topLevel; this.topLevel = false; for(int i = 0, n = suq.Arguments.Count; i < n; i++) { suq.Arguments[i] = this.VisitParameter(suq.Arguments[i]); } this.topLevel = saveTop; suq.Projection = this.VisitExpression(suq.Projection); return suq; }
internal override SqlUserQuery VisitUserQuery(SqlUserQuery suq) { this.canJoin = false; return base.VisitUserQuery(suq); }
internal override SqlUserQuery VisitUserQuery(SqlUserQuery suq) { this.disableInclude = true; return base.VisitUserQuery(suq); }
internal SqlUserRow(MetaType rowType, ProviderType sqlType, SqlUserQuery query, Expression source) : base(SqlNodeType.UserRow, rowType.Type, sqlType, source) { this.Query = query; this.rowType = rowType; }