locked
visual studio lightswitch - Search Parameters RRS feed

  • Question

  • Hi,

    I have a table with the following fields

    person_no - int

    person_name - string

    person_dob - date

    I need to build a search screen in lighswitch with parameters: person_no, year_of_birth.

    Typical query would be select * from person where person_no = @person_no and year(person_dob) = @year_of_birth

    but how this can be achieved in lightswitch??


    Thursday, September 12, 2013 5:46 AM

Answers

  • You can use the <QueryName>_PreprocessQuery method in the Write Code drop down to write a custom LINQ expression that compares the Year portion of a date property to an integer query parameter. Note that the PreprocessQuery method is only available for global queries and not for screen queries.

    Justin Anderson, LightSwitch Development Team

    • Marked as answer by Angie Xu Monday, September 23, 2013 3:13 AM
    Thursday, September 12, 2013 6:12 AM
    Moderator

All replies

  • Please see Beth's How Do I: Create Custom Search Screens in LightSwitch? video where she describes how to build a custom search screen.

    Justin Anderson, LightSwitch Development Team

    Thursday, September 12, 2013 5:51 AM
    Moderator
  • thanks for the reply.

    I have seen the video but the parameter year(person_dob) = @year is not dealt.

    it appears that there is not straight forward approach for this requirement.

    regards, laks.


    Thursday, September 12, 2013 6:06 AM
  • You can use the <QueryName>_PreprocessQuery method in the Write Code drop down to write a custom LINQ expression that compares the Year portion of a date property to an integer query parameter. Note that the PreprocessQuery method is only available for global queries and not for screen queries.

    Justin Anderson, LightSwitch Development Team

    • Marked as answer by Angie Xu Monday, September 23, 2013 3:13 AM
    Thursday, September 12, 2013 6:12 AM
    Moderator