Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6571953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:56:46+00:00 2026-05-25T14:56:46+00:00

/// <summary> /// Returns list of popular searches /// </summary> public static string[] getPopularSearches(int

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

I looked at other questions but they seem to be slightly different, I get the error:

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

I know this is probably simple, could someone point out what’s wrong here please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:56:47+00:00Added an answer on May 25, 2026 at 2:56 pm

    Sure – you’re trying to return from a method declared to return a string[], but you’re returning a query – which isn’t a string in itself. The simplest way of converting a query to an array is to call the ToArray extension method.

    However, as you’re already selecting a string array for every element in the query, that would actually return string[][]. I suspect you really want to select a single string per query element, and then convert the whole thing into an array, i.e. code like this:

    public static string[] GetPopularSearches(int sectionID, int maxToFetch)
    {
        using (MainContext db = new MainContext())
        {
            var query = from c in db.tblSearches
                        where c.SectionID == sectionID && c.Featured
                        select c.Term;
            return query.Take(maxToFetch)
                        .ToArray();
        }
    }
    

    Note that:

    • I’ve renamed the method and parameters to match .NET naming conventions
    • I’ve added a call to Take in order to use the maxToFetch parameter
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this function public static AdoEntity.Inspector GetInspectorWithInclude(int id, List<string> properties) { using (var
public static class MyExtensions { /// <summary> /// Finds the missing numbers in a
Summary: I'm trying to write a text string to a column of type varchar(max)
I have a List<string> in Model. When I write a html helper , I
[TestFixture] public class ExpandoToMessageConverterTests { /// <summary> /// CanConvertEvent /// </summary> [Test] public void
I can get the list of country names using below code, (copied from somewhere
I created a BinaryHeap<T> class. public class BinaryHeap<T> { private List<T> _heap; // Constructor
I have two stored procedures, one of which returns a list of payments, while
I have a LINQ function that returns a summary table. private DataTable CreateSummaryFocusOfEffortData() {
Hey, I'm using Levenshteins algorithm to get distance between source and target string. also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.