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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:36:58+00:00 2026-05-12T15:36:58+00:00

Something so simple, but my head is hurting over it, I’m sure I can

  • 0

Something so simple, but my head is hurting over it, I’m sure I can write this in one line when converting, but how?

IQueryable<ion> ions =FindAllions();

List<ionFormViewModel> ionFormViewModels = new List<ionFormViewModel>();

foreach (ion ion in ions)
{
     ionFormViewModel ionFormViewModel = new ionFormViewModel(ion);
     ionFormViewModels.Add(ionFormViewModel);
}
  • 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-12T15:36:58+00:00Added an answer on May 12, 2026 at 3:36 pm

    Try this:

    List<ionFormViewModel> ionFormViewModels
        = ions.Select(i => new ionFormViewModel(i)).ToList();
    

    The Enumerable.Select extension method allows you to project a new value into a new sequence for each value in your current sequence. Basically it gives you the ability to generate sequences from other sequences with a transformation step in between.

    Then the Enumerable.ToList extension method simply creates a new List<T> from the Select method’s resulting IEnumerable<T>.

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

Sidebar

Related Questions

This is probably something extremely simple but I can't get my head around it
This is probably something simple but I'm scratching my head over easing with the
I know this is probably something simple but I can't seem to find anything
I'm sure this is something simple but I've been staring at it for a
This is probably something really simple but for some reason I just can't seem
I know this is probably something simple, but I can't figure it out. When
This is probably something really simple but I cant see what! Any images I
I think i must be missing something simple here but I can't figure out
I'm trying to do something simple in JSF but I can't get it working
I'm sure this is probably something simple so I apologize ahead of time. This

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.