【发布时间】:2019-06-24 14:50:20
【问题描述】:
尝试编码
Client = new MongoClient($"mongodb://{connectionParameters}");
List<dynamic> names = Client.ListDatabases().ToList()
.Select(x => new { name = x["name"].ToString() })
.OrderBy(x => x.name)
;
但编译器显示错误
无法隐式转换类型
'System.Linq.IOrderedEnumerable'
到
'System.Collections.Generic.List'。存在显式转换(您是否缺少强制转换?)
不确定补救措施是什么。
也试过了
List<string> names = Client.ListDatabases().ToList()
.Select(x => x["name"].ToString())
;
但也出错了
无法将类型“System.Collections.Generic.IEnumerable”隐式转换为“System.Collections.Generic.List”。存在显式转换(您是否缺少演员表?)
【问题讨论】: