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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:53:55+00:00 2026-05-16T21:53:55+00:00

I need some help. What I am trying to do is show the locations

  • 0

I need some help. What I am trying to do is show the locations of a device belonging to a specific project.

On the projects page I have a button which goes to the google map. For projects I have a Projects model and controller.
I’ve got 2 tables, a table containing the location of a device and a project table. I want to display all device locations belonging to a project on a google map. The google maps part is working and I managed to show all device locations on 1 map, only problem is I can’t seem to link the devices to the project. I need some help on how to achieve this.

In the Location table ive got a foreign key to the projects table. this is a many-to-onerelation. A project can have multiple devices, but a device can only be linked to 1 project. I have defined the relation as follows in the location model:

[BelongsTo("ProjectID")]
        public Project project
        {
            get { return _project; }
            set { _project = value; }
        }

In the Location controller I use the following code(theres more but for the moment its not relevant):

public ActionResult Index()
    {
        return View(DeviceLocation.FindAll());
     }

This simply lists all locations in the location table. What I need is to list all locations where the ProjectID = the ID of the projects table. I’m coming from PHP/MYSQL and there you would simply join the 2 tables. How do I achieve this with asp mvc?

  • 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-16T21:53:56+00:00Added an answer on May 16, 2026 at 9:53 pm

    You should read up on LINQ and how to use it to query your data.

    Something like this should help:

    public ActionResult Index()
        {
            return View(DeviceLocation.Where(d=> d.ProjectId == myProjectId));
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying out Cassandra and need some help in understanding a few
I really need some help with this as I have been trying to fix
I need some help. I have been searching for days trying to find solution
I need some help trying to match a C include file with full path
Hey all i am in need of some help trying to figure out how
i need some help with creating file Im trying in the last hours to
I need some help. I am trying to shorten a full product name from
I need some help with SQL Query. I am trying to select all records
I need some help! Please. I am trying to develop a very very simple
I need some help using regex in java. Im trying to achieve 2 different

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.