Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A relational database and LINQ are poor starts for Faceting searching but I share your dream...What I see above doesn't look faceted to me in the technical hurdle sense as you can build up OR relationships dynamically to retrieve your results from the products table using PredicateBuilder. If I understand you want a query that checks a bunch of OR relationships per Alias combined with an OR relationship for each value. Any product that matches the alias and any one of the values is a match. If the alias doesn't match then you don't bother with the values. After you have generated the base query you do a group by to remove the duplicates.</p> <p>Here is an example of iterating a list of values and building up AND set of relationships query. In your case you would be building OR relationships between the aliases. In this case my queryBuilders contain a collection of values to match, I pass in the current Queryable because you need to chain the statements together.</p> <pre><code> public static IQueryable&lt;MeetingPayment&gt; GetViewSpecificQuery(IQueryable&lt;MeetingPayment&gt; query, IInvoiceViewDetail viewToUse, IEnumerable&lt;IInvoiceViewQueryBuilder&gt; queryBuilders) { Expression&lt;Func&lt;MeetingPayment, bool&gt;&gt; predicate = PredicateBuilder.True&lt;MeetingPayment&gt;(); foreach (IInvoiceViewQueryBuilder builder in queryBuilders) { Expression&lt;Func&lt;MeetingPayment, bool&gt;&gt; predicateItem = builder.GetQuery(predicate, viewToUse); if (predicateItem != null) { predicate = predicate.And(predicateItem.Expand()).Expand(); } } return query.Where(predicate.Expand()); } </code></pre> <p>This is an individual filter where an OR relationship is created between a collection of values as you are doing with 10g and 20g.</p> <pre><code>public Expression&lt;Func&lt;MeetingPayment, bool&gt;&gt; GetQuery(Expression&lt;Func&lt;MeetingPayment, bool&gt;&gt; query, IInvoiceViewDetail viewToUse) { var ids = viewToUse.InvoiceStatuses.Select(x =&gt; x.Id).ToList(); if (!ids.Any()) return null; var predicate = PredicateBuilder.False&lt;MeetingPayment&gt;(); foreach (var id in ids) { int? closure = id; predicate = predicate.Or(x =&gt; x.InvoiceStatus == (InvoiceStatusEnum) closure); } return predicate; } </code></pre> <p>Good luck.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload