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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:20:25+00:00 2026-05-25T01:20:25+00:00

I have 2 queries which work fine: var q = (from c in _context.Wxlogs

  • 0

I have 2 queries which work fine:

var  q = (from c in _context.Wxlogs

                where (SqlFunctions.DatePart("Month", c.LogDate2) == m3) && (SqlFunctions.DatePart("Year", c.LogDate2) == y1)
                group c by c.LogDate2
                into g
                orderby g.Key
                let maxTemp = g.Max(c => c.Temp)
                let minTemp = g.Min(c => c.Temp)
                let maxHum = g.Max(c => c.Humidity)
                let minHum = g.Min(c => c.Humidity)

                select new 
                           {
                               LogDate = g.Key,
                               MaxTemp = maxTemp,
                               MaxTempTime = g.FirstOrDefault(c => c.Temp == maxTemp).LogTime,
                               MinTemp = minTemp,
                               MinTempTime = g.FirstOrDefault(c => c.Temp == minTemp).LogTime,
                               MaxHum = maxHum,
                               MaxHumTime = g.FirstOrDefault(c => c.Humidity == maxHum).LogTime,
                               MinHum = minHum,
                               MinHumTime = g.FirstOrDefault(c => c.Humidity == minHum).LogTime,
                           });

var  r = (from c in _context.Wxlogs
                where
                    (SqlFunctions.DatePart("Month", c.LogDate2) == m3) &&
                    (SqlFunctions.DatePart("Year", c.LogDate2) == y1)
                group c by c.LogDate2
                    into g
                    orderby g.Key
                    let maxDew = g.Max(c => c.Dew_Point)
                    let minDew = g.Min(c => c.Dew_Point)
                    //let maxWind = g.Max(c=> c.Wind_Gust)
                    let maxRainRate = g.Max(c => c.Rain_rate_now)
                    let maxPres = g.Max(c => c.Barometer)
                    let minPres = g.Min(c => c.Barometer)

                    select new
                               {
                                   LogDate = g.Key,
                                   MaxRainRateTime = g.FirstOrDefault(c => c.Rain_rate_now == maxRainRate).LogTime,
                                   MaxPres = maxPres,
                                   MaxPresTime = g.FirstOrDefault(c => c.Barometer == maxPres).LogTime,
                                   MinPres = minPres,
                                   MinPresTime = g.FirstOrDefault(c => c.Barometer == minPres).LogTime,
                                   MinDew = minDew,
                                   MinDewTime = g.FirstOrDefault(c => c.Dew_Point == minDew).LogTime,
                                   MaxDew = maxDew,
                                   MaxDewTime = g.FirstOrDefault(c => c.Dew_Point == maxDew).LogTime,
                                   MaxRainRate = maxRainRate,

                               });

however when I try to combine them using union, in order to output the results to a WPF datgrid:

var result = r.Union(q);

the following error is thrown on the union:

Error   1   Instance argument: cannot convert from 'System.Linq.IQueryable<AnonymousType#1>' to 'System.Linq.ParallelQuery<AnonymousType#2>'

I can’t seem to find a way to make this work and any help would be appreciated.

  • 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-25T01:20:25+00:00Added an answer on May 25, 2026 at 1:20 am

    A “union” operation combines two sequences of the same type into a single set (i.e. eliminating all the duplicates). Since you clearly have sequences of two different types, you don’t want a union operation. It looks like you want a “concat” operation, which just chains two sequences together. You need something like:

    var result = r.Concat<object>(q);
    

    However, since you’re using L2E, your query will try to get executed on the server. Since your server won’t allow you to combine your two queries (due to mismatched types), you need to execute them separately and then concat the sequences on the client:

    var result = r.AsEnumerable().Concat<object>(q.AsEnumerable());
    

    The use of AsEnumerable() runs the queries on the server and brings the results to the client.

    Since it turns out that you want to combine the sequences next to each other (i.e. using the same rows in your grid but another group of columns), you actually want a join operation:

    var result = from rrow in r.AsEnumerable()
                 join qrow in q.AsEnumerable() on rrow.LogDate equals qrow.LogDate
                 select new { rrow.LogDate,
                              rrow.MaxTemp, rrow.MaxTempTime,
                              rrow.MinTemp, rrow.MinTempTime,
                              rrow.MaxHum, rrow.MaxHumTime,
                              rrow.MinHum, rrow.MinHumTime,
                              qrow.MaxRainRate, qrow.MaxRainRateTime,
                              qrow.MaxPres, qrow.MaxPresTime,
                              qrow.MinPres, qrow.MinPresTime,
                              qrow.MaxDew, qrow.MaxDewTime,
                              qrow.MinDew, qrow.MinDewTime };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two YQL queries, each of which work fine on their
i have some queries which group datasets and count them, e.g. SELECT COUNT(*) FROM
I have the following two queries which I want to get in one query.
i have SOQL query which queries for some records based on a where condition.
I'm currently trying to develop a site which queries text information. I already have
I have some code which utilizes parameterized queries to prevent against injection, but I
I have a JSP page which accepts SQL queries, performs them then returns the
I have a method which takes an array of strings as parameter and queries
I have to queries: select id, name, num from pending id, name, num 1,
I have created simple .aspx page which queries a database for some live data

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.