locked
lightswitch loading error RRS feed

  • Question

  • hi i need help please

    in my application i have a Charge table and a Payment table and a relationship one Charge to many Payments, and on my Charge table i have a computed property called AmountPaid this is the method code

           
    partial void AmountPaid_Compute(ref decimal result)
    {            
        result = Payments.Sum(p => p.Amount);  
    }

    now i'm trying to run a query like that

    partial void UnpaidCharges_PreprocessQuery(ref IQueryable<Charge> query)        
    {            
        query = query.Where(c => c.AmountPaid > c.AmountPaid);
    }

    but when executing i'm getting a

    Microsoft.LightSwitch.DataServiceOperationException was unhandled by user code
      Message=The expression is not supported.   Expression: LightSwitchApplication.Charge[].Where(c => (c.Amount > c.AmountPaid))
    Inner exception message:
    The expression is not supported.   Expression: c => (c.Amount > c.AmountPaid)
    Inner exception message:
    The expression is not supported.   Expression: c => (c.Amount > c.AmountPaid)
    Inner exception message:
    The expression is not supported.   Expression: (c.Amount > c.AmountPaid)
    Inner exception message:
    The expression is not supported.   Expression: c.AmountPaid
    Inner exception message:
    The member 'AmountPaid' on type 'LightSwitchApplication.Charge' is not supported.
      StackTrace:
           at Microsoft.LightSwitch.Utilities.Internal.LinqHelper.ExpressionVisitor.Visit(Expression exp)
           at Microsoft.LightSwitch.Utilities.Internal.LinqHelper.ExpressionMergeRewriterVisitor.Merge(Expression rootImplExpr, Expression composedDefExpr)
           at Microsoft.LightSwitch.Utilities.Internal.LinqHelper.MergeQueries(IQueryable rootImplementationQuery, IQueryable composedDefinitionQuery)
           at Microsoft.LightSwitch.ServerGenerated.Implementation.DataServiceImplementation`1.Microsoft.LightSwitch.ServerGenerated.Implementation.IServerDataServiceImplementationCore.GetQuery(String queryName, Object[] args)
           at Microsoft.LightSwitch.ServerGenerated.Implementation.DataServiceQueryProvider.QueryableWrapper`1.get_RootQuery()
           at Microsoft.LightSwitch.ServerGenerated.Implementation.DataServiceQueryProvider.QueryableWrapper`1.GetMergedExpression(Expression composedExpression)
           at Microsoft.LightSwitch.ServerGenerated.Implementation.DataServiceQueryProvider.QueryableWrapper`1.<>c__DisplayClass13`1.<ExecuteGeneric>b__12()
           at Microsoft.LightSwitch.ServerGenerated.Implementation.DataService`1.<>c__DisplayClass17`1.<LogicInvoke>b__16()
           at Microsoft.LightSwitch.Threading.DispatcherExtensions.Invoke(IDispatcher dispatcher, Action action)
           at Microsoft.LightSwitch.ServerGenerated.Implementation.DataService`1.LogicInvoke[T](Func`1 f)
           at Microsoft.LightSwitch.ServerGenerated.Implementation.DataService`1.Microsoft.LightSwitch.ServerGenerated.Implementation.IODataService.LogicInvoke[T](Func`1 f)
           at Microsoft.LightSwitch.ServerGenerated.Implementation.DataServiceQueryProvider.QueryableWrapper`1.ExecuteGeneric[TResult](Expression expression)
           at Microsoft.LightSwitch.ServerGenerated.Implementation.DataServiceQueryProvider.QueryableWrapper`1.Execute[TResult](Expression expression)
           at System.Linq.Queryable.LongCount[TSource](IQueryable`1 source)
      InnerException: 

    can someone please help me. 

    Thanks


    • Edited by M. Lerner Tuesday, September 16, 2014 2:55 PM
    Tuesday, September 16, 2014 2:52 PM

Answers

  • I don't believe that the data provider "knows" about the LightSwitch computed property, therefore the error.
    • Proposed as answer by Simon Jones [MSDL] Tuesday, September 16, 2014 3:22 PM
    • Marked as answer by Angie Xu Monday, September 29, 2014 7:45 AM
    Tuesday, September 16, 2014 3:01 PM

All replies

  • I don't believe that the data provider "knows" about the LightSwitch computed property, therefore the error.
    • Proposed as answer by Simon Jones [MSDL] Tuesday, September 16, 2014 3:22 PM
    • Marked as answer by Angie Xu Monday, September 29, 2014 7:45 AM
    Tuesday, September 16, 2014 3:01 PM
  • Ok thanks
    Tuesday, September 16, 2014 3:17 PM