12 Days of RIA – Day 7 – Search

12 Days of RIA – Day 7 – Search

  • Comments 1

I got a bit ahead of myself with my desire to move on to styling the app, and decided instead to focus on a few more pieces of business app functionality first. And so, I’d like to show an approach for doing searching on more than one attribute. I want to disclaim this a bit, as I haven’t completely thought through the depths of what should or shouldn’t be done here, but I do want to offer this as a utilitarian approach. In taking a look at the data, I saw that Artist and Album were very simple – it’s the Track table that I found to be a little more interesting:

image

I already had a way to search for Artist by name – I wanted to add a means to search for Artists by album name, track name, or even track composer. Fortunately, LINQ made this a lot easier than I initially expected. I started by adding an additional query to the domain service which took artist name, album name, track name, and track composer as arguments:

image

LINQ enabled me pass an IQueryable<Artist> through a pipeline of conditions – that enabled me to query by any combination of criteria . I’m not confident that this is the best LINQ code (in fact, I’m quite confident that it isn’t.) However, it hopefully illustrates the point:

image

I then went back to Artists.xaml and checked the data source to be sure that the FindArtistsQuery was now visible under the Artist entity

image

This enabled me to replace the artistsDataGrid based on the GetArtistsByNameQuery with the FindArtistsQuery. After a little XAML adjustment similar to the one I did when I first built the page with the GetArtistsByNameQuery, I ended up with the following:

image

This implementation could of course use some work, but I think it illustrated how to do something a little more complex than query by a single value.

Code for this is here.

  • Any postings since Day 8?

    Can't wait to see how this wraps up.

    Jerry

Page 1 of 1 (1 items)
Leave a Comment
  • Please add 2 and 5 and type the answer here:
  • Post