【发布时间】:2019-04-03 22:30:01
【问题描述】:
我正在使用 DistinctAsync 从 MongoDB 检索字符串列表。问题是结果是不同的,除了我得到一些全大写的值和一些小写的值,这当然算作不同的。
如何将.ToLower() 应用于此查询?
public async Task<List<string>> GetAllAuthorsUserNames()
{
var filter = Builders<Episode>.Filter.Where(x => x.CreatedBy != null);
var cursor = await GetCollection().DistinctAsync(o => o.CreatedBy, filter);
return cursor.ToList();
}
我试过了,但是不行:
var cursor = await GetCollection().DistinctAsync(o => o.CreatedBy.ToLower(), filter);
【问题讨论】:
-
它给了我这个错误:
Unable to determine the serialization information for o => o.CreatedBy.ToString().ToLower()
标签: c# mongodb mongodb-.net-driver