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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:58:55+00:00 2026-06-16T03:58:55+00:00

Using Entity Framework 5, the following code is invalid since I’m trying to cast

  • 0

Using Entity Framework 5, the following code is invalid since I’m trying to cast a List<string> to List<TRK_USER>. Makes sense.

List<TRK_USER> userList = db.TRK_USER.Select(t => t.USER_FIRST).ToList();

However, I would like to maintain the type of the TRK_USER object. What I would hope/expect is that I could convert that List<string> to a List<TRK_USER> and just get nulls for all of the missing properties. So in this case I would have a List<TRK_USER> where only USER_FIRST is populated with data. Is this possible with some magical extension 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-06-16T03:58:56+00:00Added an answer on June 16, 2026 at 3:58 am

    Assuming that TRK_USER has a parameterless constructor, you could do:

    List<TRK_USER> userList = db.TRK_USER
                .Select(t => new TRK_USER{ USER_FIRST = t.USER_FIRST})
                .ToList();
    

    But why would you want to do that?

    List<string> userFirstNamesList = db.TRK_USER
                .Select(t => t.USER_FIRST)
                .ToList();
    

    would give the exact same information, just without unnecessary overhead.

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

Sidebar

Related Questions

Trying to map the following schema using the Entity Framework. A Customer can have
I'm trying to make sense of a situation I have using entity framework on
I am using the Entity Framework, ASP.NET and C#3.5 I borrowed the following code
I'm trying to use Entity Framework to query database and I have following code
I am creating the Entity Framework ObjectContext per ASP.NET Request using the following code:
I'm trying out the new scaffolding features in MVC 3, using Entity Framework Code
Using the Entity Framework Code First paradigm I have defined the following objects and
I have the following table created using Entity Framework Code First approach. How do
I am using Entity Framework Code First Approach. I have following code to insert
I'm getting an error when using Entity Framework - Code First in the following

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.