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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:59:14+00:00 2026-06-03T01:59:14+00:00

Unfortunaltly I am maintaining a system that didnt take consideration into what will happen

  • 0

Unfortunaltly I am maintaining a system that didnt take consideration into what will happen once the system has millions of records.

The issue I am having is the way the code is currently written mainly the GetList method actually returns every record from the database and the filtering is done at the getfull method.

I tryed changing this by passing the id of the adjustment to the getlist method however when i try to do .Where(a=>a.Id == journalid)
i get this error

Cannot implicitly convert type ‘System.Linq.IQueryable to ‘System.Data.Objects.ObjectQuery

public Adjustment GetFull(int id) {
            var result = GetList(id).FirstOrDefault(ja => ja.Id == id);
            if(result == null) {
                throw new InvalidOperationException(
                    String.Format(" Adjustment with Id={0} not found.", id)
                );
            }
            return LoadFullActivities(result);
        }


        private IQueryable<Adjustment> GetList(int journalid) {
            return GetList(journalid,"Original", "Activities",
                "Original.Employee", "Original.Employee.EmployeeType", 
                "Original.Employee.WorkType", "Original.Employee.Department", 
                "Original.Activities", "Original.Status", 
                "Original.Approver", "Status");
        }

        private IQueryable<Adjustment> GetList(int journalid, params string[] includes) {
            var tempResult = dataContext.AdjustmentSet;
            foreach (var property in includes) {
                tempResult = tempResult.Include(property).Where(a=>a.Id == journalid) ;
            }
            return tempResult;
        }
  • 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-03T01:59:15+00:00Added an answer on June 3, 2026 at 1:59 am

    This would fix the error

    private IQueryable<Adjustment> GetList(int journalid, params string[] includes) {
             var tempResult = dataContext.AdjustmentSet.AsQueryable();
             foreach (var property in includes) {
                  tempResult = ((ObjectQuery<Adjustment>)tempResult).Include(property);
             }            
             return tempResult.Where(a=>a.Id == journalid);
          }
    

    Those Includes slow down the query. Since the query is going to get only one row (and do other joins because of the includes) I don’t think the performance is so slow. To increase the performance add indexes for each foreign key. I guess a.Id has already a clustered index.

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

Sidebar

Related Questions

I'm currently maintaining a system that shuts down in case of failure by using
I'm in charge of developing and maintaining a group of Web Applications that are
I'm currently maintaining an old plugin for Office. Current solution has a method for
I am working on maintaining someone else's code that is using multithreading, via two
I am trying to split groups of elements into groups that contain a unique
I'm currently maintaining some old code for a company. As it would happen, the
It's basically one app that is installed on multiple PC's, each install maintaining it's
I'am maintaining a GUI built using JQuery. In one part of the GUI, multiple
In C# I have an intrusive tree structure that looks like this: public abstract
This problem is a little similar to that solved by reservoir sampling , but

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.