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

  • Home
  • SEARCH
  • 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 323671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:03:09+00:00 2026-05-12T09:03:09+00:00

I have a specific problem with a bottleneck in my code that I would

  • 0

I have a specific problem with a bottleneck in my code that I would like to iron out, but I would like to know generally, for the future, how I would go about finding quickly where a bottleneck occurs without having to re-invent the wheel.

Here is my method’s code but like I said, I’d like to know how to generally find out how long the linq query is taking or how long the datatable is taking to build, etc….

public static DataTable GetPivotDataTable(this IQueryable<WbsNumber> table, Months month)
{
      FmToolDataContext dataContext = new FmToolDataContext();

      DataTable dt = new DataTable();

      dt.Columns.Add("id", typeof(string));
      dt.Columns.Add("wbsNumber", typeof(string));
      dt.Columns.Add("wbsTitle", typeof(string));
      dt.Columns.Add("number", typeof(string));
      dt.Columns.Add("vendor", typeof(string));
      dt.Columns.Add("programFund", typeof(string));
      dt.Columns.Add("committedAmount", typeof(decimal));
      dt.Columns.Add("obligatedAmount", typeof(decimal));
      dt.Columns.Add("costedAmount", typeof(decimal));
      dt.Columns.Add("costOverObligationsAmount", typeof(decimal));

      foreach (WbsNumber wbs in table)
      {
        // Get PRs for this Project Detail
        var prAmounts = dataContext.PrAmounts.Where(_pra => _pra.isCurrent && !_pra.requiresAudit
                                                    && _pra.PrDetail.isActive && _pra.PrDetail.WbsNumber == wbs
                                                                                                    && _pra.Import.fiscalYear == (int)HttpContext.Current.Session["FiscalYear"]);



        foreach(PrAmount pra in prAmounts)
        {
            DataRow row = dt.NewRow();

            row["id"] = wbs.id;
            row["wbsNumber"] = wbs.displayString;
            row["wbsTitle"] = wbs.wbsTitlesId != null ? wbs.WbsTitle.name : "(blank)";
            row["number"] = pra.PrDetail.Pr.number;
            row["vendor"] = pra.PrDetail.Pr.GetPrVendorName();
            row["programFund"] = pra.PrDetail.ProgramFund.name;
            row["committedAmount"] = pra.CommittedMonthlyRecord.GetMonth(month);
            row["obligatedAmount"] = pra.ObligatedMonthlyRecord.GetMonth(month);
            row["costedAmount"] = pra.CostedMonthlyRecord.GetMonth(month);
            row["costOverObligationsAmount"] = pra.CostOverObligationsMonthlyRecord.GetMonth(month);

            dt.Rows.Add(row);
        }

            // Get the P-Cards for this Project Detail
        var pCardAmounts = dataContext.PCardAmounts.Where(_pca => _pca.isCurrent && !_pca.requiresAudit
                                                          && _pca.PCardTransaction.isActive && _pca.PCardTransaction.WbsNumber == wbs
                                                                                                                && _pca.Import.fiscalYear == (int)HttpContext.Current.Session["FiscalYear"]);

        foreach (PCardAmount pca in pCardAmounts)
        {
            DataRow row = dt.NewRow();

            row["id"] = wbs.id;
            row["wbsNumber"] = wbs.displayString;
            row["wbsTitle"] = wbs.wbsTitlesId != null ? wbs.WbsTitle.name : "(blank)";
            row["number"] = pca.PCardTransaction.number;
            row["vendor"] = pca.PCardTransaction.bwVendorsId != null ? pca.PCardTransaction.BwVendor.name : "(blank)";
            row["programFund"] = pca.PCardTransaction.ProgramFund.name;
            row["committedAmount"] = pca.CommittedMonthlyRecord.GetMonth(month);
            row["obligatedAmount"] = pca.ObligatedMonthlyRecord.GetMonth(month);
            row["costedAmount"] = pca.CostedMonthlyRecord.GetMonth(month);
            row["costOverObligationsAmount"] = pca.CostOverObligationsMonthlyRecord.GetMonth(month);

            dt.Rows.Add(row);
        }
      }

    return dt;
}
  • 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-12T09:03:09+00:00Added an answer on May 12, 2026 at 9:03 am

    Your best bet is to download a profiling application like Red Gate ANTS Performance Profiler

    It’ll help you pinpoint the real problem (performance issues aren’t always what they seem on the surface).

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

Sidebar

Ask A Question

Stats

  • Questions 166k
  • Answers 166k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The answer to this I believe is no. What I… May 12, 2026 at 1:24 pm
  • Editorial Team
    Editorial Team added an answer Unfortunately, unless you're getting back XML, there is no XPCOM… May 12, 2026 at 1:24 pm
  • Editorial Team
    Editorial Team added an answer Code: You may need to handle other iterable types though:… May 12, 2026 at 1:24 pm

Related Questions

Server virtualization is a big thing these days, so I'm tasked at work to
I'm writing a reasonably complex web application. The Python backend runs an algorithm whose
I've read a lot recently about how writing multi-threaded apps is a huge pain
I have a performance problem related to string comparison (in Java). I'm working on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.