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 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 like this: TABLE user( id CHAR(100) text TEXT ) TABLE
Say, I have two tables like these: Table group Table user +----+-----------+ +----+----------+------+----------+ |
Have two tables with a linking table between them. USERS +-------+---------+ | userID| Username|
I have two tables with a Many-To-Many relationship like this: User( emailaddress , Name)
I have two tables, User and Company . I have joining them like this:
Say that I have two tables like those: Employers (id, name, .... , deptId).
I have two tables A and B. I would like to delete all the
I have two tables like of this structure: content (content_id, content_type, user_id, time, comment_count)
I have two tables, users and groups . A user can belong to many
I have two tables, stats and stat_log. The stat log is like this: user_id,stat_id,value,registered

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.