Esempio n. 1
0
 protected override Expression VisitMethodCall(MethodCallExpression m)
 {
     if (m.Method.DeclaringType == typeof(Queryable))
     {
         if (m.Method.Name == "Where")
         {
             _sb.Append("SELECT * FROM (");
             Visit(m.Arguments[0]);
             _sb.Append(") WHERE ");
             var lambda = (LambdaExpression)StripQuotes(m.Arguments[1]);
             Visit(lambda.Body);
             return(m);
         }
         if (m.Method.Name == "Select")
         {
             var lambda     = (LambdaExpression)StripQuotes(m.Arguments[1]);
             var projection = new ColumnProjector().ProjectColumns(lambda.Body, _row);
             _sb.Append("SELECT ");
             _sb.Append(projection.Columns);
             _sb.Append(" FROM (");
             Visit(m.Arguments[0]);
             _sb.Append(") ");
             _projection = projection;
             return(m);
         }
     }
     throw new NotSupportedException(string.Format("The method '{0}' is not supported", m.Method.Name));
 }
Esempio n. 2
0
 internal QueryBinder()
 {
     _columnProjector = new ColumnProjector(CanBeColumn);
 }