Linq chaîne de retour tableau

///<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 });
    }
}

J'ai regardé d'autres questions, mais ils semblent être un peu différent, j'obtiens l'erreur:

Cannot implicitly convert type 'System.Linq.IQueryable<string[]>' to 'string[]'

Je sais que c'est probablement simple, quelqu'un pourrait-il point de ce qui ne va pas ici, s'il vous plaît?

  • Est-il une raison particulière pour laquelle vous avez besoin de retourner un tableau? IEnumerable<String> serait préférable, dans la plupart des cas, à moins que le code d'appel exige expressément un tableau (peu probable)
InformationsquelleAutor Tom Gullen | 2011-09-09