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

  • SEARCH
  • Home
  • 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 5848507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:52:08+00:00 2026-05-22T12:52:08+00:00

I know IQueryable yields no result but just an expression builder, my problem is

  • 0

I know IQueryable yields no result but just an expression builder, my problem is how can actually use it to execute query and return the set as List to be able to bind it on a grid.

  IQueryable query = _campaignManager.GetCampaign(filter, values);

  // this line returns error
  List<Campaign> campaigns = query.Cast<Campaign>().ToList();

  grdCampaigns.DataSource = campaigns;
  grdCampaigns.DataBind();

additional details: GetCampaign()

    public IQueryable GetCampaign(string filter, params object[] values)
    {
        string parameters = string.Empty;
        foreach (object obj in values)
        {
            parameters += obj.ToString() + ",";
        }

        parameters.Remove(parameters.Count() - 1, 1);

        var query = context.Campaigns.Where(filter, parameters)
           .Select("new(CampaignID,CampaignName)");

        return query;
    }

I’m using DynamicQueryable for dynamic linq queries

The .Select Extension method of the DynamicQueryable

     public static IQueryable Select(this IQueryable source, string selector, params object[] values)
    {
        if (source == null) throw new ArgumentNullException("source");
        if (selector == null) throw new ArgumentNullException("selector");
        LambdaExpression lambda = DynamicExpression.ParseLambda(source.ElementType, null, selector, values);
        return source.Provider.CreateQuery(
            Expression.Call(
                typeof(Queryable), "Select",
                new Type[] { source.ElementType, lambda.Body.Type },
                source.Expression, Expression.Quote(lambda)));
    }

IQueryable .Where() extension

       public static IQueryable Where(this IQueryable source, string predicate, params object[] values)
    {
        if (source == null) throw new ArgumentNullException("source");
        if (predicate == null) throw new ArgumentNullException("predicate");
        LambdaExpression lambda = DynamicExpression.ParseLambda(source.ElementType, typeof(bool), predicate, values);
        return source.Provider.CreateQuery(
            Expression.Call(
                typeof(Queryable), "Where",
                new Type[] { source.ElementType },
                source.Expression, Expression.Quote(lambda)));
    }

thanks…

  • 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-22T12:52:08+00:00Added an answer on May 22, 2026 at 12:52 pm

    IQueryable can be of type T e.g.
    IQueryable query=+CampaignManager.GetCampaign

    but since you are using IQueryable you can use

    var enumerator= c.GetEnumerator();
                while (enumerator.MoveNext())
                {
                 //add these records to some collection say Collection or Campaign or Create any entity with Name and Id and then assign that collection to DataSource    
                }
    

    i have tried that it’s working you can proceed wit it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my query i need to return IEnumerable but i dont know if this
Can I convert a IQueryable result to a injected object on the fly? I
ok, I know this is asked a million times, but I still can't seem
Does anyone know how I can get my results currently in qry IQueryable object
That can be silly question but I really don't know the reason. // i
I know that I can do something like $int = (int)99; //(int) has a
I know this might be a no-brainer, but please read on. I also know
I know, I would have thought the answer was obviously no as well, but
I know there is a registry key indicating the install directory, but I don't
I know I must be missing something, but in a while statement how does

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.