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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:15:53+00:00 2026-06-02T23:15:53+00:00

I am new to MVC3 DB has a table called users (id,name,username,lat,lon). I do

  • 0

I am new to MVC3

DB has a table called users (id,name,username,lat,lon). I do not have access to the database.

I created entity model using the above table. Then, I created a SearchController and Search View. On the index page I display the list of all users. Also, I created a form on the page that searches the table using the username. After clicking on the details link I show the details page where I display the user’s details.

Now I need to display other users that are within a mile of the selected user. I already have the sql query to get the list of other users that are within a mile of the selected user (This is a sql query). I need to show this list on Details page.

I created a custom class model.

public class SearchDetailsViewModel
{
    public decimal id { get; set; }
    public string name { get; set; }
    public string username { get; set; }
    public Nullable<decimal> lat { get; set; }
    public Nullable<decimal> lon { get; set; }
    public string profile_img_url { get; set; }
    public IQueryable<user> usersWithinAMile { get; set; }
}

I am not sure if this is the right approach. Also, I do not know how I would intialize this class.

Any help or suggestion is really appreciated.

  • 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-02T23:15:55+00:00Added an answer on June 2, 2026 at 11:15 pm

    Yes, you are on the right track, you get the data from your SQL into the class, and then to the view, in the ActionResult, like this:

    using System.Collections.Generic;
    
    public ActionResult Index() {
        var data = new List<SearchDetailsViewModel>();
        // foreach row in your SQL
        var s = new SearchDetailsViewModel();
        s.lat = -42.00000M;
        // more data added to the s object here
        data.Add(s);
        // end loop
    
        return View("ThePage", data);
    }
    

    Then on your view itself you would do something like this:

    @foreach (var s in Model) {
        // output your values on the page
    }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As I have been following a MusicStore tutorial, new MVC3 project created a following
My new MVC3 web application allows users to store some information about themselves, and
I'm somewhat new to MVC3, so I have a few questions... I am creating
I'm new to MVC (MVC3) so not sure about the best way to implement
I'm new to MCV and I'm learning MVC3. I created a model and a
i have a problem with the asp.net MVC3. when i create a new project
I'm using MVC3 with C# code. I have a table in my SQL Server
So I have this application in ASP MVC 3. My database has two tables:
I am new to MVC3 and Jquery. Maybe i am not taking the right
I have 2 table in db: MixedType(id and name) and Block(id, name, idMixedType). I

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.