我通過轉換現有的項目和我堅持將如下的VB LINQ代碼自學C#的過程是:轉換VB的LINQ to C#
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
其中Products As ObservableCollection(Of ProductModel)
我mananged到目前爲止,轉換這麼多:
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};
'小組由我的難倒。任何幫助將是巨大的......
如果它有幫助任何人,這是代碼屬於我想要轉換和添加到頁面的項目:http:// www .codeproject.com/KB/Silverlight的/ ListDragDropSL.aspx – Graeme 2011-04-13 01:37:23