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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:17:17+00:00 2026-06-17T06:17:17+00:00

I have the following code to convert a table to its pivot. IQueryable<MeterReadingsForChart> meterReadings

  • 0

I have the following code to convert a table to its pivot.

IQueryable<MeterReadingsForChart> meterReadings = MeterReadingManager.GetCustomerMeterReadings(customer.sno, MeterType, Meter, startDate, endDate, DateTimeManager.GetTimeIntervalTypeById(DateRangeType)).AsQueryable();

// meterReadings Output:
// Customer  Value ReadingTypes
// cust1       235           T1
// cust1       241           T2
// cust1       765           T3
// cust1       247           T4
// cust1       967        Total
// ..........

var table = MeterReadingManager.GetMeterReadingsPivot(meterReadings, MeterType);

// table Output (pivot of meterReadings):
// Customer     T1     T2    T3    T4    Total
// cust1       235    241   765   247      967
// ............

and I have a string array of ReadingTypes:

string[] selectedValues = Parameters.Split(','); 
// For example output : { "T1", "Total" }

I want to get pivot column dynamically. Using the above array. My expected pivot table:

// filtered pivot from meterReadings pivot Output:
// Customer     T1    Total
// cust1       235      967
// ............

How can I do this? Dynamically select or another way?

Also the conversion function is :

return (from m in meterReadings
        group m by new { date = m.ReadDate } into g
        select new
        {
           ReadDate = g.Key.date.ToString("dd.MM.yyyy - HH:mm:ss"),
           T1 = (from t1 in g
                where t1.Name == "T1"
                select t1.Value.ToString("0.00 " + t1.Unit + "")).FirstOrDefault(),
           T2 = (from t2 in g
                where t2.Name == "T2"
                select t2.Value.ToString("0.00 " + t2.Unit + "")).FirstOrDefault(),
           T3 = (from t3 in g
                where t3.Name == "T3"
                select t3.Value.ToString("0.00 " + t3.Unit + "")).FirstOrDefault(),
           Total_T1 = (from t1 in g
                      where t1.Name == "Toplam T1"
                      select t1.Value.ToString("0.00 " + t1.Unit + "")).FirstOrDefault(),
           Total_T2 = (from t1 in g
                       where t1.Name == "Toplam T2"
                       select t1.Value.ToString("0.00 " + t1.Unit + "")).FirstOrDefault(),
           Total_T3 = (from t1 in g
                      where t1.Name == "Toplam T3"
                      select t1.Value.ToString("0.00 " + t1.Unit + "")).FirstOrDefault(),
           Reactive = (from t1 in g
                      where t1.Name == "Reaktif"
                      select t1.Value.ToString("0.00 " + t1.Unit + "")).FirstOrDefault(),
           Capasitive = (from t2 in g
                        where t2.Name == "Kapasitif"
                        select t2.Value.ToString("0.00 " + t2.Unit + "")).FirstOrDefault()
           }).AsQueryable<object>();

Thanks…

  • 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-17T06:17:19+00:00Added an answer on June 17, 2026 at 6:17 am

    I solved it :

    var table = MeterReadingManager.GetMeterReadingsPivot(meterReadings, MeterType).Select("new (" + Parameters + ")");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code to convert my JSON dataset to html table. I
I have used following code to convert string to json and parse it. String
I have the following code to convert the type of the matrix using cv::Mat.convertTo()
I have the following code that is meant to convert milliseconds into hours, mins
I have the following code sample: float val = 16777216.0F; var badResult = Convert.ToDecimal(val);
I have the following FORTRAN code which I need to convert to C or
I have the following JavaScript code which I like to convert to jQuery but
I have never used Foxpro before. Can you convert the following Foxpro code into
I have the following code to convert a date (from a database entry) into
How to convert Varchar to Int in sql server 2008. i have following code

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.