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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:15:08+00:00 2026-06-11T05:15:08+00:00

I am working on an example asp.net project using MVC, but my database is

  • 0

I am working on an example asp.net project using MVC, but my database is a live one which I can’t make changes to (technically it’s the test version of this database but my point is changes to the database aren’t possible).

I use the UserID from the asp_Users table to store who makes changes to various aspects of the system, and I want to start showing the user name in various front-end tables, but how do I link the tables to get this user name?

So to clarify, I’m going to want to do this for several tables throughout the system so I was hoping I could do it using LINQ.

I can get the info I want from using the join query, but how do I pass this to my View to use?

        var plans = from users in db.aspnet_Users
                           join import in db.Plan_Imports
                           on users.UserId.ToString()
                           equals import.User_ID

                           select new
                           {
                               Date = import.Date,
                               UserName = users.UserName
                           };

Sample tables

asp_Users

UserID

UserName

…

table1

ID

field1

field2

…

User_ID <— ref to asp_Users

table2

ID

field1

field2

…

User_ID <— ref to asp_Users

  • 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-11T05:15:10+00:00Added an answer on June 11, 2026 at 5:15 am

    The solution provided by Shyju worked perfectly, and it wasn’t too complex to do, however I decided that I didn’t think using LINQ was appropriate in this case as the code was getting out of hand for what should be a simple call.

    What I did instead was use a stored procedure to get the information, and saved it to a complex object which I passed to my view.

    The code is now much neater and easier to manage, as the code above became just

    var plans = db.SP_SelectImports();  
    

    Read more about stored procedure mapping here: http://dotnet.dzone.com/news/mapping-stored-procedure

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

Sidebar

Related Questions

I'm working through the NerdDinner ASP.NET MVC 1.0 example. I have it all working
I have a Asp.net project with complex calculation in database. for example: i need
I am working on an ASP.NET MVC project and I am trying to get
I've an Asp.net MVC website, in which I'm using entity framework in my data
I'm using asp.net mvc 3 for a project and already using the server and
I'm working through the SportsStore example from Pro ASP.NET MVC 3 Framework . At
I'm working on asp.net (C#) project which include some page files (aspx, aspx.cs) and
I created a stongly typed view in an ASP.Net MVC project I'm working on,
I am using a plugin system on an ASP.NET MVC application I am working
Working with ASP.NET MVC, KnockoutJS and I am using Require JS. I have a

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.