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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:31:39+00:00 2026-06-05T08:31:39+00:00

I have the following code: var allWorkorders = (from wo in context.WORKORDERs join wot

  • 0

I have the following code:

var allWorkorders =

            (from wo in context.WORKORDERs
            join wot in context.WORKORDERTYPEs on wo.wot_oi equals wot.wotyoi
            join pri in context.PRIORITies on wo.prio_oi equals pri.priooi
            join s in context.SITEs on wo.BEparn_oi equals s.siteoi
            where wo.audt_created_dttm.Value.Year >= now.Year - 3 && wo.audt_created_dttm.Value.Year >= 2006
                && wo.audt_created_dttm < timeframe && (s.id == "NM" || s.id == "TH") &&
                (wo.clsdt_date ?? new DateTime(3000, 01, 01)) < DateTime.Now
            group pri by new {s.id, pri.prioid, MonthNum = (wo.clsdt_date ?? new DateTime(3000, 01, 01)).Year * 100 +
                (wo.clsdt_date ?? new DateTime(3000, 01, 01)).Month} into groupItem
            orderby groupItem.Key.MonthNum, groupItem.Key.id
            select new {groupItem.Key.id, groupItem.Key.prioid, groupItem.Key.MonthNum, Unit = groupItem.Count()});

            allWorkorders.GroupBy(x => new { x.id, x.MonthNum }).Select(x => new {x.Key.id, x.Key.MonthNum,
            Denominator = x.Sum(y => y.Unit), Numerator = x.Where(y => SqlMethods.Like(y.prioid, "1%") || 
            SqlMethods.Like(y.prioid, "6%")).Sum(y => y.Unit), Data_Indicator = DATA_INDICATOR,
            Budgeted = budgetedPlannedOutageHrs, Industry_Benchmark = INDUSTRY_BENCHMARK,
            Comments = comments, Executive_Comments = executiveComments, 
            Fleet_Exec_Comments = fleetExecComments}).ToList();

I want to create a for loop:

for (int counter = 0; counter < allWorkorders.Count; counter++)
{
    var item = allWorkorders[counter];
    ......

However, I get the following error: ” ‘<‘ cannot be applied to operands of type ‘int’ and ‘method group'”

So even though I have allWorkorders going to ToList() it’s not being recognized as a list.

What am I doing wrong? I have done this in the past, the biggest difference being that in the past cases my ToList was at the end of the select statement.

  • 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-05T08:31:42+00:00Added an answer on June 5, 2026 at 8:31 am

    ToList() returns a result. You need something like

    var newList = allWorkorders.GroupBy(x => ...).Select(x => ...).ToList();
    
    • 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: var tagToPosts = (from t2p in dataContext.TagToPosts join t
I Have following code with LINQ var q = (from web in DataContext.Webs select
I have the following code: var currentUser = (from i in _dbContext.Users where i.FirstName
I have the following code: var columnNames = (from autoExport in dataContext.AutoExports where autoExport.AutoExportTemplate
I have the following code: var from = 0, step = 5; function showNext(list)
I have the following code: var thing = (from t in things where t.Type
I have the following code var query = from lookup in dataset.Tables[MBDDX_LOOKUP].AsEnumerable() where lookup.Field<string>(lookup_value)
I have the following code: var searcher = new ManagementObjectSearcher(SELECT Name, Path FROM Win32_share);
I have the following code: var data= from row in table.AsEnumerable() group row by
I have the following code: var devices = from d in ctx.Devices.Include(DeviceGroups) where d.DeviceEnabled

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.