コード例 #1
0
		internal override SqlExpression VisitClientQuery(SqlClientQuery cq)
		{
			Type clientElementType = cq.Query.NodeType == SqlNodeType.Multiset ? TypeSystem.GetElementType(cq.ClrType) : cq.ClrType;
			ICompiledSubQuery c = this.provider.CompileSubQuery(cq.Query.Select, clientElementType, cq.Parameters.AsReadOnly());
			cq.Ordinal = this.subQueries.Count;
			this.subQueries.Add(c);
			return cq;
		}
コード例 #2
0
		internal static SqlClientQuery Extract(SqlSubSelect subquery, IEnumerable<SqlParameter> parentParameters)
		{
			SqlClientQuery cq = new SqlClientQuery(subquery);
			if(parentParameters != null)
			{
				cq.Parameters.AddRange(parentParameters);
			}
			SubSelectDuplicator v = new SubSelectDuplicator(cq.Arguments, cq.Parameters);
			cq.Query = (SqlSubSelect)v.Visit(subquery);
			return cq;
		}
コード例 #3
0
		internal override SqlExpression VisitClientQuery(SqlClientQuery cq)
		{
			SqlSubSelect query = (SqlSubSelect)this.VisitExpression(cq.Query);
			SqlClientQuery nq = new SqlClientQuery(query);
			for(int i = 0, n = cq.Arguments.Count; i < n; i++)
			{
				nq.Arguments.Add(this.VisitExpression(cq.Arguments[i]));
			}
			for(int i = 0, n = cq.Parameters.Count; i < n; i++)
			{
				nq.Parameters.Add((SqlParameter)this.VisitExpression(cq.Parameters[i]));
			}
			return nq;
		}
コード例 #4
0
		internal override SqlExpression VisitClientQuery(SqlClientQuery cq)
		{
			return cq;
		}
コード例 #5
0
ファイル: SqlVisitor.cs プロジェクト: modulexcite/LinqToSQL2
 internal virtual SqlExpression VisitClientQuery(SqlClientQuery cq) {
     for (int i = 0, n = cq.Arguments.Count; i < n; i++) {
         cq.Arguments[i] = this.VisitExpression(cq.Arguments[i]);
     }
     return cq;
 }
コード例 #6
0
		internal override SqlExpression VisitClientQuery(SqlClientQuery cq)
		{
			// block where clauses from being lifted out of a client-materialized sub-query
			Scope save = this.current;
			this.current = null;
			SqlExpression result = base.VisitClientQuery(cq);
			this.current = save;
			return result;
		}
コード例 #7
0
		private Type GenerateClientQuery(SqlClientQuery cq, LocalBuilder locInstance)
		{
			Type clientElementType = cq.Query.NodeType == SqlNodeType.Multiset ? TypeSystem.GetElementType(cq.ClrType) : cq.ClrType;

			gen.Emit(OpCodes.Ldarg_0); // ObjectReaderBase
			this.GenerateConstInt(cq.Ordinal); // iSubQuery

			// create array of subquery parent args
			this.GenerateConstInt(cq.Arguments.Count);
			gen.Emit(OpCodes.Newarr, typeof(object));

			// intialize arg values
			for(int i = 0, n = cq.Arguments.Count; i < n; i++)
			{
				gen.Emit(OpCodes.Dup);
				this.GenerateConstInt(i);
				Type clrType = cq.Arguments[i].ClrType;
				if(cq.Arguments[i].NodeType == SqlNodeType.ColumnRef)
				{
					SqlColumnRef cref = (SqlColumnRef)cq.Arguments[i];
					if(clrType.IsValueType && !TypeSystem.IsNullableType(clrType))
					{
						clrType = typeof(Nullable<>).MakeGenericType(clrType);
					}
					this.GenerateColumnAccess(clrType, cref.SqlType, cref.Column.Ordinal, null);
				}
				else
				{
					this.GenerateExpressionForType(cq.Arguments[i], cq.Arguments[i].ClrType);
				}
				if(clrType.IsValueType)
				{
					gen.Emit(OpCodes.Box, clrType);
				}
				this.GenerateArrayAssign(typeof(object));
			}

			MethodInfo miExecute = typeof(ObjectMaterializer<>).MakeGenericType(this.compiler.DataReaderType)
															   .GetMethod("ExecuteSubQuery", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			Diagnostics.Debug.Assert(miExecute != null);
			gen.Emit(GetMethodCallOpCode(miExecute), miExecute);

			Type actualType = typeof(IEnumerable<>).MakeGenericType(clientElementType);
			gen.Emit(OpCodes.Castclass, actualType);

			Type resultType = typeof(List<>).MakeGenericType(clientElementType);
			this.GenerateConvertToType(actualType, resultType);

			return resultType;
		}
コード例 #8
0
		internal override SqlExpression VisitClientQuery(SqlClientQuery cq)
		{
			if(!_isDebugMode)
			{
				throw Error.InvalidFormatNode("ClientQuery");
			}
			_commandStringBuilder.Append("client(");
			for(int i = 0, n = cq.Arguments.Count; i < n; i++)
			{
				if(i > 0) _commandStringBuilder.Append(", ");
				this.Visit(cq.Arguments[i]);
			}
			_commandStringBuilder.Append("; ");
			this.Visit(cq.Query);
			_commandStringBuilder.Append(")");
			return cq;
		}
コード例 #9
0
		internal override SqlExpression VisitClientQuery(SqlClientQuery cq)
		{
			// pass control back to parent
			return this.parent.VisitClientQuery(cq);
		}
コード例 #10
0
		internal override SqlExpression VisitClientQuery(SqlClientQuery cq)
		{
			this.FoundHierarchy = true;
			return cq;
		}