This question is locked. New answers and comments are not allowed.
Hi all,
I need some help with the following case:
Tables
- Product
- Keyword
- ProductKeyword (only ID's)
Each product can have one or more keywords and vice versa.
So I have a many-to-many solution. What I want is the following:
On my webpage I want to select one or more keywords. When I click 'Search', I need a result of product items which all match the selected keywords.
This is the code based on one keyword:
How can I do this?
Regards,
Daniel
I need some help with the following case:
Tables
- Product
- Keyword
- ProductKeyword (only ID's)
Each product can have one or more keywords and vice versa.
So I have a many-to-many solution. What I want is the following:
On my webpage I want to select one or more keywords. When I click 'Search', I need a result of product items which all match the selected keywords.
This is the code based on one keyword:
/// <summary>
/// Search for products
/// </summary>
/// <param name="itemsPerPage"></param>
/// <returns></returns>
public
List<Product> SearchProducts(
int
from,
int
max, List<Keyword> filter,
out
int
totalitems)
{
try
{
// FILTER ON KEYWORDS
var items = context.Products.Where(x => x.Visible ==
true
);
totalitems = items.Count();
return
items.Where(x => x.Visible ==
true
).Skip(from).Take(max).ToList();
}
catch
(Exception ex)
{
throw
ex;
}
}
How can I do this?
Regards,
Daniel