/// <summary>
/// Returns list of popular searches
/// </summary>
public static string[] getPopularSearches(int SectionID, int MaxToFetch)
{
using (MainContext db = new MainContext())
{
return (from c in db.tblSearches where c.SectionID == SectionID && c.Featured select new[] { c.Term });
}
}
我看了看其他的问题,但他们似乎略有不同,我得到的错误:LINQ的返回字符串数组
Cannot implicitly convert type 'System.Linq.IQueryable<string[]>' to 'string[]'
我知道这可能是简单的,可能有人指出,什么是错在这里请?
是否有特殊原因需要返回数组? IEnumerable将在大多数情况下更可取,除非调用代码明确需要数组(不太可能) –
MattDavey