Error Compiled expressions cannot be inspected and therefore not pushed to the server.

5 posts, 0 answers
  1. devoas
    devoas avatar
    69 posts
    Member since:
    Dec 2009

    Posted 19 Jan 2010 Link to this post

    Hi,

    I am getting this error when I combined two predicate (and/or) and try to fetch data based on resultant predicate. 

    Thanks,
    devoas
  2. devoas
    devoas avatar
    69 posts
    Member since:
    Dec 2009

    Posted 20 Jan 2010 Link to this post

    var predicate = ExpressionBuilder.False<SalesMaster>();  
    predicate = predicate.Or(c => c.TranNumb==2);  
    predicate = predicate.Or(c => c.CustomerId ==2);  
    var query = from p in scope.Extent<SalesMaster>().Where(predicate) select p;  
    var result = query.ToList();  

    Above Code is generating following Error :

    System.NotSupportedException was unhandled
      Message="Compiled expressions cannot be inspected and therefore not pushed to the server."
      Source="Telerik.OpenAccess.Query"
      StackTrace:
           at Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(Type type, Int32 elementAt, Object[] groupResolutionParamValues)
           at Telerik.OpenAccess.Query.ExpressionExecution.PerformDatabaseQuery[T](Piece`1 piece, Object[] grpVals)
           at Telerik.OpenAccess.Query.Piece`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
           at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
           at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
           at DALTest.Form1.button4_Click(Object sender, EventArgs e) in C:\Test\DALTest\Form1.cs:line 92
           at System.Windows.Forms.Control.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ButtonBase.WndProc(Message& m)
           at System.Windows.Forms.Button.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(Form mainForm)
           at DALTest.Program.Main() in C:\Test\DALTest\Program.cs:line 23
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:
  3. DevCraft banner
  4. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 21 Jan 2010 Link to this post

    Hello devoas,

    We are not sure what kind of Linq query is actually executed as we do not know the structure of your ExpressionBuilder class. Can you give us some more insight into the issue so we can reproduce it on our side as well?

    Kind regards,
    Zoran
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. devoas
    devoas avatar
    69 posts
    Member since:
    Dec 2009

    Posted 21 Jan 2010 Link to this post

    Hi Zoran,

    Thanks for your reply and sorry that I forget to write the details of ExpressionBuilder. Its based on Linqkit.
     Following is the Code...

     public static Expression<Func<T, bool>> True<T> () { return f => true; } 
     public static Expression<Func<T, bool>> False<T> () { return f => false; }
     public static Expression<Func<T, bool>> Or<T> (this Expression<Func<T, bool>> expr1,Expression<Func<T, bool>> expr2) 
     { 
     var invokedExpr = Expression.Invoke (expr2, expr1.Parameters.Cast<Expression> ()); 
     return Expression.Lambda<Func<T, bool>>(Expression.OrElse (expr1.Body, invokedExpr), expr1.Parameters); 
     }

     public static Expression<Func<T, bool>> And<T> (this Expression<Func<T, bool>> expr1,Expression<Func<T, bool>> expr2) 
     { 
     var invokedExpr = Expression.Invoke (expr2, expr1.Parameters.Cast<Expression> ()); 
     return Expression.Lambda<Func<T, bool>>(Expression.AndAlso (expr1.Body, invokedExpr), expr1.Parameters); 
     }

    Thanks
    devoas
  6. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 26 Jan 2010 Link to this post

    Hello devoas,

    I suggest you use the approach that was provided by a colleague of mine in the following forum for you.

    Kind regards,
    Zoran
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
DevCraft banner