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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:31:41+00:00 2026-06-04T20:31:41+00:00

Im trying to do this…. var entity = landingPages.Select(x = new MyClass { name

  • 0

Im trying to do this….

var entity = landingPages.Select(x = new MyClass { name = x.name, age = x.age });

The only problem is that age is actually a coolection so I thought I would do this…

var entity = landingPages.Select(x = new MyClass { name = x.name, age.add(x.age) });

But it dont work. Is this possible?

  • 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-04T20:31:42+00:00Added an answer on June 4, 2026 at 8:31 pm
    var entity = landingPages.Select(x => new MyClass
    {  //this is an initialization block.  Only Property Assignment is allowed.
      name = x.name,
      age.add(x.age)  //arbitrary statements are not allowed in initialization blocks.
    });
    

    You didn’t say which age was a collection (LandingPage’s age or MyClass’ age).

    If it’s the LandingPage’s age, then: convert the single value into a collection.

    IEnumerable<MyClass> query = landingPages.Select(x => new MyClass
    {
      name = x.name,
      age = new List<int>() { x.age } //this is a collection initializer
    });
    

    If it’s MyClass’ age, then: convert the collection to a single value.

    IEnumerable<MyClass> query = landingPages.Select(x => new MyClass
    {
      name = x.name,
      age = x.age.Sum()
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying this query SELECT round( avg( DATEDIFF( CURRENT_DATE, age ) /365 )
i've being trying this without success: select * from table where name regexp '^[:alpha:]{2}$'
When trying this query: SELECT * FROM superpart WHERE Brick_subpart_id = 603 OR 145;
Im trying this, but when i press it it dont changes, it only displays
I was trying this problem, http://www.spoj.pl/problems/TWOSQ/ . We have to find the number of
I'm trying this jQuery way of pub-sub and it works only partially: <button id=button1>click1</button>
I am trying this function, however something is wrong. I stored the name John
I am trying this code findUsStateOrMileSpinnerState.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> adapterView, View
I'm trying to execute this script through JDBC (it's SQL Server): DECLARE @var VARCHAR(10)
I am trying this query, but didn't work INSERT INTO single_user (location_home.id_location_home ) SELECT

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.