太陽の下ですべての翻訳サービスを試してこの構文を正しくしましたが、select ステートメントの最初の部分 (ピリオドまでgroupby キーワードの直前)
ローカルで作業しようとしているオンラインの例からの元の c# ステートメント:
public IEnumerable<TagGroup> GetTagGroups()
{
var tagGroups =
// extract the delimited tags string and session id from all sessions
DbSet.Select(s => new { s.Tags, s.Id })
.ToArray() // we'll process them in memory.
// split the "Tags" string into individual tags
// and flatten into {tag, id} pairs
.SelectMany(
s =>
s.Tags.Split(_tagDelimiter, StringSplitOptions.RemoveEmptyEntries)
.Select(t => new { Tag = t, s.Id })
)
// group {tag, id} by tag into unique {tag, [session-id-array]}
.GroupBy(g => g.Tag, data => data.Id)
// project the group into TagGroup instances
// ensuring that ids array in each array are unique
.Select(tg => new TagGroup
{
Tag = tg.Key,
Ids = tg.Distinct().ToArray(),
})
.OrderBy(tg => tg.Tag);
return tagGroups;
}
私がVBでそれに最も近いもの:
Public Function GetTagGroups() As IEnumerable(Of TagGroup)
' extract the delimited tags string and session id from all sessions
' we'll process them in memory.
' split the "Tags" string into individual tags
' and flatten into {tag, id} pairs
' group {tag, id} by tag into unique {tag, [session-id-array]}
' project the group into TagGroup instances
' ensuring that ids array in each array are unique
Dim tagGroups = DbSet.[Select](Function(s) New With { _
s.Tags, _
s.Id _
}).ToArray().SelectMany(Function(s) s.Tags.Split(_tagDelimiter, StringSplitOptions.RemoveEmptyEntries).[Select](Function(t) New With { _
Key .Tag = t, _
s.Id _
})).GroupBy(Function(g) g.Tag, Function(data) data.Id).[Select](Function(tg) New With { _
Key .Tag = tg.Key, _
Key .Ids = tg.Distinct().ToArray() _
}).OrderBy(Function(tg) tg.Tag)
Return tagGroups
End Function
これにより、ビジュアル スタジオ 2012 の IntelliSense では、ステートメントの最初の部分の最初の行にある "DbSet" から、一番下にある ".GroupBy" の前の最後の括弧までに青色の下線が引かれます。エラーは、「アクセス可能な 'SelectMany' をこれらの引数で呼び出すことができないため、オーバーロードの解決に失敗しました」です。
これはコード例であるため、ローカルで実行して理解するためにvbに変換しようとしていますが、linqの経験が十分ではないため、これを試して対処する方法が完全に失われています。これは私の現在の理解をはるかに超えているため、単純な構文エラーまたは最初から最後までの完全なハッシュである可能性があります。
任意のポインタに非常に感謝します。