Help With Expressions

5 posts, 0 answers
  1. Gerry Leco
    Gerry Leco avatar
    5 posts
    Member since:
    Jan 2010

    Posted 04 Nov 2014 Link to this post

    For simple things like adding two numeric columns I'm in good shape but I have two use cases that I can't seem to figure out how to express.
    The data structure is an Account object at the root that has 1 or more Detail child objects.  Detail has a few different string properties.
    What I want to be able to do is filter down to Account rows where it has at least one Detail object where its property is equal to a certain string.
    In C# it would be like this:
    var foo = db.Accounts.Where(a => a.Details.Any(b => b.HCPCS == "55555"));

    Also,
    I wanted to know if there way any way to cast strings to ints in the editor.
    Something like
    int.Parse(Field) > 50
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 06 Nov 2014 Link to this post

    Hi Gerry,

    Here is the help article indicating how you can define Lambda expressions via RadExpressionEditor. 

    You still need to reset the Item of the editor to the root ViewModel that will contain the base of the query in order for it to work. 

    Hope this helps. 

    Regards,
    Nick
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Gerry Leco
    Gerry Leco avatar
    5 posts
    Member since:
    Jan 2010

    Posted 06 Nov 2014 in reply to Nick Link to this post

    Yes, I read the documentation, it did help with this case.
  5. Gerry Leco
    Gerry Leco avatar
    5 posts
    Member since:
    Jan 2010

    Posted 06 Nov 2014 in reply to Gerry Leco Link to this post

    Did not help I meant to say.  I need to be able to get at a certain property in the child object for filtering.
  6. Nick
    Admin
    Nick avatar
    593 posts

    Posted 07 Nov 2014 Link to this post

    Hi Gerry,

    The help article actually specifies how you can mod your query in order for it to work:
    Tasks.Where(SubTasks.Count > 2)

    SubTasks is a collection that is part of every Task. The query you see is the same as:
    item => item.Tasks.Where(param0 => param0.SubTasks.Count > 2)

    As to the custom nature of your query, you will probably have to experiment a bit in order to get the exact syntax you need. 

    Regards,
    Nick
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready