我一直在尝试将下面的 foreach 语句转换为 LINQ 语句,但似乎无法理解它。欢迎任何帮助。
IDictionary<string, IDictionary<string, ICollection<string>>> Highlights { get; set; }
foreach (var r in matchingProducts.Highlights)
{
string szKey = r.Key;
var ar = r.Value.ToArray();
foreach (var s in ar)
{
string szCat = s.Key;
var sr = s.Value.ToArray();
foreach (var t in sr)
{
string szName = t;
//todo: update the corresponding matchingProduct records
// using the return values from szKey, szCat, szName
}
}
}
配套产品
public class Product {
[SolrUniqueKey("id")]
public string Id { get; set; }
[SolrField("sku")]
public string SKU { get; set; }
[SolrField("name")]
public string Name { get; set; }
[SolrField("manu_exact")]
public string Manufacturer { get; set; }
[SolrField("cat")]
public ICollection<string> Categories { get; set; }
[SolrField("features")]
public ICollection<string> Features { get; set; }
[SolrField("price")]
public decimal Price { get; set; }
[SolrField("popularity")]
public int Popularity { get; set; }
[SolrField("inStock")]
public bool InStock { get; set; }
[SolrField("timestamp")]
public DateTime Timestamp { get; set; }
[SolrField("weight")]
public double? Weight { get; set;}
}