3

I've been searching for a good way of doing multiple "where" filters on an entity collection from linq. There are lots of sites that use a filter for their searches on the side, like ebay.

The technique used is called a "drill down" filter. Now I'm trying to find the right way of implementing this technique in my 3-tier model working with Linq-to-Entities.

The technique uses the earlier used received entity collection and narrows it down with some kind of filter, but there are multiple filters which can both be applied and removed even within the same "category" of filtering.

Hope somebody finds me the right link to a tutorial or a method of how to use this in a proper way.

Julian
  • 1,105
  • 2
  • 26
  • 57
  • Besides directly down voting, if someone flags your question as spam, I'm pretty sure it automatically down votes the question. – Bala R May 18 '11 at 18:48
  • Still my question is serious and I'm really looking for the best way of doing this. The links are all from reliable sites (like ebay). I hope that the votedown won't interfere with my chance of getting a good answer. – Julian May 18 '11 at 18:51
  • @Charles, ok atleast thats cleared up for me now. But I still don't got any answers on my question. Hope somebody come up with an answer soon! Oh and about the answering yourself, I'll look into my questions and answer them whenever I solved one of them. – Julian May 18 '11 at 19:25
  • Bet it is an encrypted id field more than a filter – TheGeekYouNeed May 18 '11 at 19:43
  • I've cleared the SPAM flags on this question, as it is a serious question. However, you need some context to go with the links. If the links break, your question loses all context. Please consider revising. – Tim Post May 18 '11 at 19:47
  • @Tim, Thanks, I'll reconsider my links. And I've probably found the name of the "filtering method" to, which is "drill down." – Julian May 18 '11 at 19:49

1 Answers1

0

In my experience, each "filter" on the side maps to a field in the database. This makes it simple to do a filter:

var result = db.Table
                 .Where(t => t.Name.Contains(ddlName.Text))
                 .Where(t => t.Attribute1.Contains(Attribute1.Text));
                 .Where(t => t.Attribute2.Contains(Attribute2.Text));

Obviously you can substitue .Equals() where it makes sense, I've used this on several webapps with great success. This becomes a bit more trickey when the filters you want do not map directly to fields in your database, but a similar approach can be taken.

Nate
  • 30,286
  • 23
  • 113
  • 184
  • Thanks Nate, but then whenever dllName.Text == "" then the database would probably return null. And it wouldnt really neat to put 100 if loops around it, would it? – Julian May 21 '11 at 10:11