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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:01:04+00:00 2026-05-29T20:01:04+00:00

In my DAL I have a data access object that retrievs database records to

  • 0

In my DAL I have a data access object that retrievs database records to an EntityObject List:

private List<EntityObject> entities;

var pList = context.Products.Where(...);
entities = new List<EntityObject>(pList);

To work with this List in my BI layer I need to enumarate through this List<EntityObject> as a list of Product objects. I can easily convert back like this:

var pList = Data.Entities.Select(p => p as Product);

but doesn’t this create a copy of the List<EntityObject> doubling my memory footprint for this collection which would be a concern with large collections?

If so, is there a way to enumarete through this List<EntityObject> as List<Product> instead of converting back to Product and than enumerating through that copy?

  • 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-29T20:01:08+00:00Added an answer on May 29, 2026 at 8:01 pm

    but doesn’t this create a copy of the List doubling my
    memory footprint for this collection which would be a concern with
    large collections?

    No, this would just make a copy of the references to the entities, so that should be of no concern.

    Also a safer way to do your cast would be:

    var pList = Data.Entities.OfType<Product>().ToList();
    

    Or you can just directly enumerate through the products:

    foreach(var product in Data.Entities.OfType<Product>())
    {
       //..
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data access layer (DAL) that is written in ASP.NET 3.5 and
Let's say we have a solution with the following structure: Project.DAL - Data access
I have an ASP.NET page A that uses a data layer assembly DAL .
I've got an object that handles in memory caching for my data access layer
We have data that's updated nightly in a database residing in the same instance
I have used a lot of static methods in Data Access Layer (DAL) like:
In a project we have implemented the data access layer (DAL) with a visual
I have a (DAL) Data Access Layer (but this question is relevant for DAOs
I have two executables that access a DLL containing Data Access Layer objects Each
I have a DAL class library that is included in my program as 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.