【发布时间】:2022-01-23 17:43:46
【问题描述】:
在 IQueryable 上运行 Select 后我遇到了这个问题
'$project 或 $group 不支持 {document}。'
public Interface IVideo
{
....
public string File { get; set;}
public bool Categorized { get; set;}
public IMovie Movie { get; set;}
....
}
public Interface IMovie
{
....
public List<string> Langauge {get; set;}
....
}
public static Dictionary<string, int> GetLanguage(string isp)
{
//Repository.GetVideos() is IQueryable<IVideo>
var videos = Repository.GetVideos().Where(q => q.Categorized && (
q.File == isp ||
q.File == "st"));
var language = videos.SelectMany(q => q.Movie.Language).Select(e => e);
var ql = from x in language
group x by x
into g
let count = g.Count()
orderby count descending
select new {g.Key, count}; // issue is here
return ql.ToDictionary(item => item.Key, item => item.count);
}
我该如何解决这个问题?
【问题讨论】:
标签: c# mongodb iqueryable