I am currently participating in C # converting an existing project and forcing the following vb linq code to be converted:
Dim outStuff = From tt In (From t In Products.SelectMany(Function(p) If(p.tags IsNot Nothing, p.tags, New ObservableCollection(Of TagModel))) Group By tagName = t.name, v = (Aggregate p In Products Where If(p.tags IsNot Nothing, p.tags.Contains(t), Nothing) Into Sum(p.views)), nl = (Aggregate p In Products Where If(p.tags IsNot Nothing, p.tags.Contains(t), Nothing) Into Sum(p.num_likes)) Into g = Group, Count()) Group By name = tt.tagName Into Count = Sum(tt.Count), viewsTotal = Sum(tt.v), num_likesTotal = Sum(tt.nl) Select name, Count, viewsTotal, num_likesTotal
where Products As ObservableCollection(Of ProductModel)
I changed it so far:
var x = Products.SelectMany(p => (p.tags != null) ? p.tags : new ObservableCollection<TagModel>()); var tags = from t in x group t by t.name into g select new { tagname=g.First().name};
"The group" I am entwined. Any help would be excellent ...
source share