【发布时间】:2014-08-28 19:59:04
【问题描述】:
以下代码是单次转移投票(STV)系统中的第二次运行。
' Elected Officials From Previous Count with excess votes
Dim Officials = From o In PlatoDB.ElectionCounts
Where o.Count = ElectionCount - 1 AndAlso o.Votes > Quota
Order By o.Votes Descending
If ElectionCount - 1 = 1 Then
For Each o In Officials
Dim oVotes = GetVotes(ElectionId)
Dim oInheritableVotes = From vote In oVotes
Where vote.Preference = 1 AndAlso
vote.LinkId = o.CandidateId AndAlso
vote.Vote_Headers.Used = False
Select vote.Vote_Headers
我目前的问题是在这里我需要按 Vote_HeaderID 分组并以最小偏好检索投票。到目前为止我得到的最好的是最小偏好和投票的父级(Vote_HeaderId)。
' Gets the next available preference which hasn't been elected
Dim NextPreference = From inheritedVote In oInheritableVotes
From v In PlatoDB.Votes
Where v.Vote_HeaderId = inheritedVote.Id AndAlso
v.Preference > 1 AndAlso
Not Officials.Select(Function(f) f.CandidateId).Equals(v.LinkId)
Group v By v.Vote_HeaderId Into Group
Select Vote_HeaderId, MinVote = Group.Min(Function(f) f.Preference)).ToList
Next
Else
End If
有没有人建议我如何直接获得 vote_id 而不必使用当前列表来获得实际投票。
【问题讨论】:
-
@CheGueVerra 我知道我需要做什么我只需要稍微推动一下,因为我已经接近了,只是还没有。
标签: .net vb.net linq entity-framework-6