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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:53:25+00:00 2026-06-14T07:53:25+00:00

In my Person table is a RequestedLocation column which stores location IDs. The IDs

  • 0

In my Person table is a RequestedLocation column which stores location IDs. The IDs match the LocationId column in the Locations table, the Locations table also has the text location names, in the LocatioName column.

In my view, I need to display the string LocationName in the view which has the Person model passed to it. The view will be displaying a List of people in a telerik grid. CUrrently it works great, except the RequestedLocation column is all integers.

I am populating all my grids with methods containing LINQ queries. Here is the method that currently works:

    public List<Person> GetPeople()
    {
        var query = from p in _DB.Person.ToList()
                    select p;

        return query.ToList();
    }

Here is the regular SQL query that works, and I need to convert into LINQ:

SELECT ApplicantID
      ,FirstName
      ,LastName
      ,MiddleName
      ,DateofBirth
      ,Gender
      ,RequestedVolunteerRole
      ,RequestedVolunteerLocation
      ,l.LocationName
  FROM Form.Person p
  JOIN dbo.Location l ON p.RequestedVolunteerLocation = l.LocationID
  Order BY ApplicantID 

Here is my attempt to convert to LINQ:

    public List<NewApplicantViewModel> GetPeople()
    {
        var query = from pl in _DB.Person.ToList()
                    join l in _Elig_DB.Locations.ToList() on pl.RequestedVolunteerLocation equals l.LocationID
                    select new
                    {
                        pl.RequestedVolunteerLocation = l.LocationName

                    };
        return query.ToList();

The number of errors I get from this are numerous, but most are along the lines of:

Cannot convert from type Annonymous to Type List<NewAPplicantModel>

and

Invalid annonymous type declarator.

Please help, and thank you for reading my post.

Oh, and I have only been programming for a couple months, so if I am going about this all wrong, please let me know. Only thing I have to stick with is the table structure because it is an existing app that I am updating, and changing the location or person tables would have large consequences.

  • 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-06-14T07:53:26+00:00Added an answer on June 14, 2026 at 7:53 am
    public List<NewApplicantViewModel> GetPeople()
    {
        var query = from pl in _DB.Person
                    join l in _Elig_DB.Locations on pl.RequestedVolunteerLocation 
                    equals l.LocationID
                    select new NewApplicantViewModel
                    {
                        LocationName = l.LocationName,
                        otherPropery = p.Property
                    };
        return query.ToList();
     }
    

    Beware of calling _DB.Person.ToList() it will load all persons from DB because ToList() immediately executes the query and the join would be performed in memory (not in DB).

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

Sidebar

Related Questions

My Django app has a Person table, which contains the following text in a
I have a Person table that has a nullable AddressId in it which is
I have a database structure that has a Person table which contains fields such
Suppose I have table Person table Employee, which inherits Person. I want to get
I have a table Person which contains 2 fields.In my another database i have
I have a table called Person which I have already mapped in hibernate I
I have a Person table. Each person can have many names in the PersonNames
I have a table that stores a person's information with close to 10 million
I have an ORM class called Person, which wraps around a person table: After
I have a problem. Imagine this data model: [Person] table has: PersonId, Name1 [Tag]

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.