在我的項目中,我試圖使用Linq實現分面搜索。我不希望使用Solr的,Lucene的,等等linq中的分面搜索
我的DB:
產品
+----+------+
| id | name |
+----+------+
| 1 | prod1|
+----+------+
| 2 | prod2|
+----+------+
屬性
+----+--------+---------+
| id | name | alias |
+----+--------+---------+
| 1 | Weight | weight |
+----+--------+---------+
| 2 | Height | height |
+----+--------+---------+
值
個+----+---------------+---------+---------+
| id | attribute_id | value | alias |
+----+---------------+---------+---------+
| 1 | 1 | 10 g | 10m |
+----+---------------+---------+---------+
| 2 | 1 | 20 g | 20m |
+----+---------------+---------+---------+
| 3 | 2 | 10 m | 10m |
+----+---------------+---------+---------+
| 4 | 2 | 20 m | 20m |
+----+---------------+---------+---------+
products_values
+---------------+---------+
| product_id | value_id|
+---------------+---------+
| 1 | 1 |
+---------------+---------+
| 1 | 2 |
+---------------+---------+
| 1 | 3 |
+---------------+---------+
| 2 | 1 |
+---------------+---------+
查詢用於選擇,例如:site.com/filter/weight=10g_20g;height=10h/
POCO模型過濾器:
public class Filter
{
public string Attribute { get; set; }
public IEnumerable<Value> Values{ get; set; }
}
此模型中使用自定義模型綁定。但從現在開始,填充過濾器模型後,我不知道如何實現選擇產品並在過濾器(啓用計數的產品)中選擇「活動」值。填充過濾器和產品表必須分開?或者,可能是單一行動?我很高興看到使用Linq實現分面搜索的分步指南。