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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:02:45+00:00 2026-06-05T08:02:45+00:00

I need to add data to view model using LINQ My view model is

  • 0

I need to add data to view model using LINQ
My view model is :

public class SearchScrapViewModel 
{ 
public WClass wClass{get; set;} 
public SClass sClass{get; set;} 
public YClass yClass { get; set; } 
} 

public class WClass 
{ 
public string title { get; set; } 
public string link { get; set; } 
} 
public class SClass 
{ 
public string title { get; set; } 
public string link { get; set; } 
} 
public class YClass 
{ 
public string title { get; set; } 
public string link { get; set; } 
}

and i need to use these 3 classes with 3 different LINQ query and then pass data to return View(SearchScrapViewModel);

var wikians = //LINQ Logic 
select new SearchScrapViewModel 
{ 
wClass.link = link.Attributes["href"].Value, //Error: I am not able to add to wClass 
wClass.title = link.InnerText 
}; 

and similarly to other classes

and then pass to return View(SearchScrapViewModel); so that i can access all the 3 classes in View of this controller

How to do that?

  • 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-05T08:02:46+00:00Added an answer on June 5, 2026 at 8:02 am

    You forgot to create an instance of your WClass:

    select new SearchScrapViewModel {
        wClass = new WClass { 
            link = link.Attributes["href"].Value,
            title = link.InnerText 
        }
    }; 
    

    Alternatively, you could make WClass (and SClass and YClass) a struct instead of a class, then you don’t need to instantiate it. In that case, however, you should probably make the struct immutable.

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

Sidebar

Related Questions

I am using the Add-on builder and I need to receive binary data (image).
I am using EF4 and trying to add a SQL view into the model.
I have a form and I need to add some data from database before
I need to add conditions depending on params data. @users = User.where('id', params[:id]) unless
With df <- data.frame(v1=c(1:5), v2=c(9,32,6,17,11)) I need to add a new column v3 with
I need to calculate and add to a data frame multiple new columns based
I have a table of data that I need to dynamically add a column
I am using the Model-View pattern on a small application I'm writing. Here's the
I am writing an app using the MVVM (Model-View-ViewModel) pattern and am leveraging the
I am using a Remote validation attribute on my view model to validate a

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.