title: List(Of T) groupby visual basic
body: <p>i want to Group Movies in gridview by category. i have C# code and i want to convert it to Visual Basic.</p>
  
  <pre><code>var moviesByCategories = movies.GroupBy(x =&gt; x.Category)
              .Select(x =&gt; new MovieCategory { Title = x.Key, Items = x.ToList() });
  </code></pre>
  
  <p>i tried the following code but it gives me an error.</p>
  
  <pre><code>Dim query = From film In movies Group film.Title By Category = film.Category Into grpTitle = Group
  </code></pre>
  
  <p>UPDATE 
  used converter.telerik.com suggested by Plutonix</p>
  
  <pre><code>Dim moviesByCategories = movies.GroupBy(Function(x) x.Category).[Select](Function(x) New MovieCategory() With { _
  Key .Title = x.Key, _
  Key .Items = x.ToList() _
  })
  </code></pre>
  
  <p>But the code doesn't work gives the following error
  <img src="https://i.stack.imgur.com/AQm2a.png" alt="enter image description here"></p>
  
  <p>My classes
  1. MoviePageViewModel</p>
  
  <pre><code>Public Class MoviesPageViewModel
      Private _Items As List(Of MovieCategory)
      Public Property Items() As List(Of MovieCategory)
          Get
              Return _Items
          End Get
          Set(ByVal value As List(Of MovieCategory))
              _Items = value
          End Set
      End Property
  
      Sub New()
          Dim movies As List(Of Movie) = New List(Of Movie)
         'adding movies to movies list
          Dim moviesByCategories = movies.GroupBy(Function(x) x.Category).[Select](Function(x) New MovieCategory() With { _
  Key .Title = x.Key, _
  Key .Items = x.ToList() _
   })
          Items = moviesByCategories
      End Sub
  End Class
  </code></pre>
  
  <p>2.Movie class</p>
  
  <pre><code>Public Class Movie
      Private _Title As String
      Public Property Title() As String
          Get
              Return _Title
          End Get
          Set(ByVal value As String)
              _Title = value
          End Set
      End Property
      Private _Subtitle As String
      Public Property Subtitle() As String
          Get
              Return _Subtitle
          End Get
          Set(ByVal value As String)
              _Subtitle = value
          End Set
      End Property
      Private _Image As String
      Public Property Image() As String
          Get
              Return _Image
          End Get
          Set(ByVal value As String)
              _Image = value
          End Set
      End Property
      Private _Category As String
      Public Property Category() As String
          Get
              Return _Category
          End Get
          Set(ByVal value As String)
              _Category = value
          End Set
      End Property
      Sub New(title As String, category As String, subtitle As String, img As String)
          _Title = title
          _Subtitle = subtitle
          _Image = img
          _Category = category
      End Sub
  End Class
  </code></pre>
  
  <ol start="3">
  <li><p>MovieCategory</p>
  
  <pre><code>Public Class MovieCategory
  Private _Title As String
  Public Property Title() As String
      Get
          Return _Title
      End Get
      Set(ByVal value As String)
          _Title = value
      End Set
  End Property
  Private _Items As List(Of Movie)
  Public Property Items() As List(Of Movie)
      Get
          Return _Items
      End Get
      Set(ByVal value As List(Of Movie))
          _Items = value
      End Set
  End Property
  
    End Class
  </code></pre>
  
  <p>UPDATE 
  now i get this error after using the code provided by Tom
  <img src="https://i.stack.imgur.com/tMfGf.png" alt="enter image description here"></p></li>
  </ol>