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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:55:43+00:00 2026-05-12T13:55:43+00:00

I have a plain old CLR object which is essentially a wrapper for two

  • 0

I have a plain old CLR object which is essentially a wrapper for two entity framework objects, I’m doing this so I can pass this wrapper object to a strongly typed view in the MVC framework. My foo wrapper class is very simple:

public class FooWrapper
{
    public FooWrapper(Foo f, Bar b)
    {
        this.FooObject = f;
        this.BarObject = b;
    }

    public Foo FooObject { get; private set; }
    public Bar BarObject { get; private set; }
}

What I have so far for my ListFoosWithBars function is as follows:

public IEnumerable<FooWrapper> ListFoosWithBars(int userID)
{
    IEnumerable<Bar> tempBar = ListBarsByUserID(userID);
    IEnumerable<FooWrapper> results = (from f in _entities.FooSet
                                       join b in tempBar on f.ID equals b.foos.ID
                                       select new FooWrapper(f, b));
    return results;
}

This doesn’t work because evidently LINQ to Entities doesn’t support parametrized initialization, an exception is thrown that says just that: “Only parameterless constructors and initializers are supported in LINQ to Entities.” I was wondering if there is another way to achieve this same result?

  • 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-12T13:55:43+00:00Added an answer on May 12, 2026 at 1:55 pm

    IF you add a parameterless constructor to your FooWrapper and then use object initialization instead, like so:

    public IEnumerable<FooWrapper> ListFoosWithBars(int userID)
    {
        IEnumerable<Bar> tempBar = ListBarsByUserID(userID);
    
        IEnumerable<FooWrapper> results = (
            from f in _entities.FooSet
            join b in tempBar on f.ID equals b.foos.ID
            select new FooWrapper()
            {
                FooObject = f, 
                BarObject = b
            });
    
        return results;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a POCO (Plain Old CLR Object) public Foo { public virtual int
I have read about POCO (Plain old CLR (or C#) object) here ,and confused
I have a POCO (plain old clr object) stored in session, and would like
I have a javascript widget that can be inserted on an a plain-old html
Are there any tools which help manage plain old c structures? I have a
I have some data type which, if I were to use plain old C
In JPA the Entities are nice annotated Plain Old Java Objects. But I have
I'm trying to create a sort of 'template' in plain old html, which can
I have a struct/class which is partiall Plain Old Data (POD). struct S {
I do have lots of plain old activity-based apps in the Play Store. Since

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.