All In query

36 views
Skip to first unread message

Jason Dentler

unread,
Jan 6, 2013, 2:35:48 PM1/6/13
to rav...@googlegroups.com
Hi,

I'm stuck on a query.

Each community has a list of amenities that it offers: Pool, Golf Course, etc. This is a simple array of strings.

On my search form, I list all of the amenities available and let the user check off the ones they must have. 

Among other criteria, I need to return the communities that offer all of the amenities. I haven't found a way to accomplish this.

This is part of a complicated, dynamic search form with facet search, so I can't stray too far without breaking a lot of other stuff.

Here's my code so far:


Here's what my form looks like. (I hope this works.)
Inline image 1

- J
image.png

Jason Dentler

unread,
Jan 6, 2013, 4:08:05 PM1/6/13
to rav...@googlegroups.com
Okay. Scratch that. I figured out a way to pull it off.

            if (searchCriteria.Amenities != null && searchCriteria.Amenities.Any())
            {
                foreach (var amenity in searchCriteria.Amenities)
                {
                    var amenity2 = amenity;
                    query = query.Where(r => r.Amenities.Any(s => s == amenity2));
                }
            }
 
image.png

Oguzhan Topcu

unread,
Jan 6, 2013, 6:18:22 PM1/6/13
to rav...@googlegroups.com
additionally you can use Session.Advanced.LuceneQuery for dynamic query build with or/and operators

foreach (var amenity in searchCriteria.Amenities)
                {
                    var 
amenity2 = amenity;
                    query = query.Where(r => r.Amenities.Any(s => s == amenity2)).Or();
                }


6 Ocak 2013 Pazar 23:08:05 UTC+2 tarihinde Jason Dentler yazdı:
Reply all
Reply to author
Forward
0 new messages