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

  • Home
  • SEARCH
  • 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 6215199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:00:44+00:00 2026-05-24T07:00:44+00:00

I have two tables like User and UserInfo UsersInfo UserId UserName Email Password LastLoginDate

  • 0

I have two tables like User and UserInfo

  • UsersInfo
    UserId
    UserName
    Email
    Password
    LastLoginDate
  • User
    UserId
    FirstName
    LastName
    PhoneNumber

I would like to get data from database using join. i have written following query to get result from both above table.

public ViewResult Index()
        {
            List<UserDetailModel> UsersCompleteDetails = (from u in db.Users
                                                          join l in db.UsersInfoes on u.UserId equals l.UserId
                                                          select new { u.UserId, u.UserName, u.Email, u.Password, u.LastLoginDate, l.FirstName, l.LastName, l.PhoneNumber }).ToList<UserDetailModel>;
            return View(UsersCompleteDetails);
        }

and following is the Custom Class Model

**public class UserDetailModel
{
    //Following details are comes from UsersInfo Table
    public string UserId { get; set; }
    public string UserName { get; set; }
    public string Email { get; set; }
    public string Password { get; set; }
    public DateTime LastLoginDate { get; set; }
    //Following details are comes from User Table
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string PhoneNumber { get; set; }
}**

but do not have any idea about how could i map the custom class with query result? right now it is giving me following Error:

Cannot convert method group ‘ToList’ to non-delegate type ‘System.Collections.Generic.List’. Did you intend to invoke the method?

  • 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-24T07:00:45+00:00Added an answer on May 24, 2026 at 7:00 am

    The specific error you are getting is because you don’t have parenthesis after the call to ToList ie: ToList<...>(). However you have a larger issue in that you are trying to convert a list of an anonymous type to a typed list.

    You could use a number of libraries out there to help you map your Entities to Model objects and vice versa like AutoMapper but you could also just create conversion methods on the model and data objects themselves or use automatic property initialization which would be similar to your generation of the anonymous type.

    The example below should work for your case, it isn’t formatted pretty but should get the point across.

    public ViewResult Index()
    {
        List<UserDetailModel> UsersCompleteDetails = (from u in db.Users
                                                      join l in db.UsersInfoes on u.UserId equals l.UserId into userInfo
                                                      from info in userInfo.DefaultIfEmpty()
                                                      select new UserDetailModel() {  
            UserId = u.UserId, 
            UserName = u.UserName, 
            Email = u.Email, 
            Password = u.Password, 
            LastLoginDate = u.LastLoginDate, 
            FirstName = l.FirstName, 
            LastName = l.LastName, 
            PhoneNumber = l.PhoneNumber 
        }).ToList();
    
        return View(UsersCompleteDetails);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables in my database who looks like this: User: userid(int) username(varchar)
I have two tables, in which one user can have several contacts: User(UserId, UserName)
I have two tables users(id, username, password) and user_badges(user_id, badge_id, badge_slot) I would like
If i have two tables like user table-u userid | name 1 | lenova
I have two tables user and log. I would like to join the user
I have two tables like this: TABLE user( id CHAR(100) text TEXT ) TABLE
I have two tables. USER user_id password FRIEND_LIST user_id friend_id If user 1 is
I have two tables with a Many-To-Many relationship like this: User( emailaddress , Name)
I have two tables like these: USER id name MESSAGE id sender_id receiver_id As
I have two classes, namely User & UserProfile User contains(few attributes like):- userId loginId

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.