1
4行のループを書くのではなく、新しいList
(実際にはIEnumerable
)をLINQで作成したいと思います。ラムダ式をLINQに供給することができ、その式を使用してリストの要素をマップすることができますが、List
が保持する型は変更されますか?LINQを使用して異種タイプを保持するリストを作成しますか?
// My List of objects
List<MyDBDocType> myDBDocs = ...;
// How they are mapped
BsonDocument myDBDocAsBson = myDBDocs[0].ToBsonDocument();
// Function signature that takes a List that holds a separate type
MyDocCollection.InsertManyAsync([IEnumerable<BsonDocument> documents], ...);