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 843091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:04:10+00:00 2026-05-15T06:04:10+00:00

hiya, i have the following code but when i try and create a new

  • 0

hiya, i have the following code but when i try and create a new IQuerable i get an error that the interface cannot be implemented, if i take away the new i get a not implemented exception, have had to jump back and work on some old ASP classic sites for past month and for the life of me i can not wake my brain up into C# mode.

Could you please have a look at below and give me some clues on where i’m going wrong:

The code is to create a list of priceItems, but instead of a categoryID (int) i am going to be showing the name as string.

        public ActionResult ViewPriceItems(int? page)
    {
        var crm = 0;
        page = GetPage(page);

        // try and create items2
        IQueryable<ViewPriceItemsModel> items2 = new IQueryable<ViewPriceItemsModel>();

        // the data to be paged,but unmodified
        var olditems = PriceItem.All().OrderBy(x => x.PriceItemID);

        foreach (var item in olditems)
        {
            // set category as the name not the ID for easier reading
            items2.Concat(new [] {new ViewPriceItemsModel {ID = item.PriceItemID,
                  Name = item.PriceItem_Name,
                  Category = PriceCategory.SingleOrDefault(
                       x => x.PriceCategoryID == item.PriceItem_PriceCategory_ID).PriceCategory_Name,
                  Display = item.PriceItems_DisplayMethod}});
        }


        crm = olditems.Count() / MaxResultsPerPage;
        ViewData["numtpages"] = crm;
        ViewData["curtpage"] = page + 1;

        // return a paged result set
        return View(new PagedList<ViewPriceItemsModel>(items2, page ?? 0, MaxResultsPerPage));
    } 

many thanks

  • 1 1 Answer
  • 2 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-15T06:04:11+00:00Added an answer on May 15, 2026 at 6:04 am

    you do not need to create items2. remove the line with comment try and create items2. Use the following code. I have not tested this. But I hope this works.

    var items2 = (from item in olditems
                          select new ViewPriceItemsModel
                              {
                                  ID = item.PriceItemID,
                                  Name = item.PriceItem_Name,
                                  Category = PriceCategory.SingleOrDefault(
                                     x => x.PriceCategoryID == item.PriceItem_PriceCategory_ID).PriceCategory_Name,
                                  Display = item.PriceItems_DisplayMethod
                              }).AsQueryable();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When running the following block of code, FF and Chrome output typeof(hiya) = string
Hiya I am very new to C#, infact this is basically my first task
I have the following model: class test_data_urls(models.Model): url = models.CharField(max_length=200, db_index=True) I want to
I have been trying to get this to work and can't. I have a
Hiya im trying to write a code for basic 1D Monte-Carlo integration. To do
I wanted to use the following code from here: How can I save all
I have a page with lots of comments. The code structure is as follows:
hiya i have a massive job trying to sort thousands of records all is
Hiya - been pointed at you guys by a friend of mine. I have
Hiya, I'm trying to make a small loop which presents an error when the

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.