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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:31:56+00:00 2026-05-17T15:31:56+00:00

I have this code that works. public class HelloWorldController : Controller { UAStagingEntities db

  • 0

I have this code that works.

public class HelloWorldController : Controller
{
    UAStagingEntities db = new UAStagingEntities();

    public ActionResult Index(int? id)
    {
        var depot = db.CSLA_DEPOT.Where(c => c.DEPOT_ID == id.Value);

        return View(depot.ToList());
     }

}

What I don’t know how to do is display a view with results from two queries. How would I create the view to show both depot and address? and how would I code the return statement?

public class HelloWorldController : Controller
{
    UAStagingEntities db = new UAStagingEntities();

    public ActionResult Index(int? id)
    {
         var depot = db.CSLA_DEPOT.Where(c => c.DEPOT_ID == id.Value);
         var Address = db.CSLA_ADDRESS.Where(a => a.CSLA_DEPOT.DEPOT_ID == id.Value);

         return View(depot.ToList());
    }
}

EDIT *

I added this model

    namespace CustomerCareMVC.Models
{
    public class CSLA_StagingModel

    {

        public List<CSLA_DEPOT> depots { get; set; }
        public List<CSLA_ADDRESS> addresses { get; set; }

    }

}

And added this method in the controller

    public ActionResult ShowAllTables() 
    {


        var model = new CSLA_StagingModel()
        {

            depots = db.CSLA_DEPOT.Where(c => c.DEPOT_ID == 10065),
            addresses = db.CSLA_ADDRESS.Where(a => a.CSLA_DEPOT.DEPOT_ID == 10065),
        };


        return View(model);

    }

I get squiggly line under these two lines

            depots = db.CSLA_DEPOT.Where(c => c.DEPOT_ID == 10065),
            addresses = db.CSLA_ADDRESS.Where(a => a.CSLA_DEPOT.DEPOT_ID == 10065),

with this error message

Error 1 Cannot implicitly convert type ‘System.Linq.IQueryable’ to ‘System.Collections.Generic.List’. An explicit conversion exists (are you missing a cast?) C:\CustCareMVC\CustomerCareMVC\CustomerCareMVC\Controllers\HelloWorldController.cs 59 26 CustomerCareMVC

  • 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-17T15:31:57+00:00Added an answer on May 17, 2026 at 3:31 pm

    You would need to create a ViewModel that has the following paramters:

    public IQueryable<CSLA_DEPOT> depots {get; set;}
    public IQueryable<CSLA_ADDRESS> addresses {get; set;}
    

    You would then need to create an instance of this new View Model in your controller like so:

    var model = new ViewModelName(){
        depots = db.CSLA_DEPOT.Where(c => c.DEPOT_ID == id.Value),
        addresses = db.CSLA_ADDRESS.Where(a => a.CSLA_DEPOT.DEPOT_ID == id.Value),
    };
    

    You would then need to pass this model to your view like so:

    return View(model);
    

    In your view you would access the two different collections like so:

    Model.depots
    Model.addresses
    

    Hope this helps, leave me a comment if you have any questions.

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

Sidebar

Related Questions

No related questions found

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.