0

데이터베이스에서 태그를 선택하려고합니다. 나는 처음 EF 코드 4.2, vbnet 및 mvc 3을 사용하고있다. 지금 일찍 내가 처음에 함수를 구현했을 때 제대로 작동하고 중복 태그를 찾지 않았다. 어쨌든, 이제 그것은 중복 태그를 당기고 있습니다. 누군가 논리를 결함이 있는지 살펴보고 알려줄 수 있습니까?그룹 별 구문이 작동하지 않는 것 같습니다

Using _rdsqlconn As New RDSQLConn 
      Dim tags 
      tags = _rdsqlconn.Tags.GroupBy(Function(t) New TagViewModel() With {.TagId = t.TagId, .Tag = t.TagWord}).Select(Function(a) a.Key).ToList() 
      ' Dim tags = _rdsqlconn.Tags.Distinct.ToList ' this didnt work 

      Return tags 
     End Using 

Public Class TagViewModel 
     Dim _rdsqlconn As RDSQLConn 

     Property TagId As Int32 
     Property Tag As String 
     ReadOnly Property TagCount As Int32 
      Get 
       Using _rdsqlconn As New RDSQLConn 
        Dim t = _rdsqlconn.Tags.ToList 
        Return t.Count 
       End Using 
      End Get 
     End Property 
     ReadOnly Property PostCount As Int32 
      Get 
       Using _rdsqlconn As New RDSQLConn 
        Dim p = _rdsqlconn.Posts.ToList 
        Return p.Count 

       End Using 
      End Get 
     End Property 

답변

1

수정 됨. .TagId 부분을 꺼냈다. 이제 중복 태그가 없습니다.