Question : C# Linq statement conversion to VB.NET

I have been converting some C# code to VB for use in a web project.  I'm not familiar with LINQ, but translating this code has been an extremely educational experience.  I apologize if the code snippet does not format correctly. I've been able to convert all of the code so far except for the following statement:

 
1:
2:
3:
4:
messagesByOtherUsername = (from m in messages
                                           let otherUser = m.SenderUsername == username ? m.RecipientUsername : m.SenderUsername
                                           group m by otherUser into mbu
                                           select new JsMessagesByUsername { Username = mbu.Key, Messages = mbu.Select(m => new JsMessage { Id = m.MessageId, Sender = m.SenderUsername, Msg = m.MessageContents }).ToList() }).ToList();

Answer : C# Linq statement conversion to VB.NET

Hi jfeltjfelt;

Not able to check this out right now but that should be correct.

Fernando
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
messagesByOtherUsername = (From m In messages _
                           Let otherUser = IIF(m.SenderUsername = username, m.RecipientUsername, m.SenderUsername) _
                           Group By oUser = otherUser Into mbu = Group _
                           Select New JsMessagesByUsername { _
                               .Username = oUser, _
                               .Messages = mbu.Select(Function(m) New JsMessage { _
                                                          .Id = m.MessageId, _
                                                          .Sender = m.SenderUsername, _
                                                          .Msg = m.MessageContents _
                                                      }).ToList() _
                           }).ToList()
Random Solutions  
 
programming4us programming4us