Page 1 of 1

I couldn't realize

Posted: Thu 01 Jul 2010 14:26
by maxcpr
Hi guys i am really couldn't realize why there is no way to get SQL request from DataContext if i only know ExpressionTree that describe this request!!!

Please somebody who understand or guess why it so give me suggestion.

Posted: Mon 05 Jul 2010 14:34
by AndreyR
Try the following code. expr is an Expression instance, context is a DataContext instance.

Code: Select all

      var query = Expression.Lambda(expr).Compile().DynamicInvoke();
      string s = context.GetCommand((IQueryable)query).CommandText;