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

The Archive Base Latest Questions

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

I have managed to get the following working: var transactions = from t in

  • 0

I have managed to get the following working:

var transactions = from t in context.Transactions
                   group t.Create_Date_Time by t.Participation_Id
                       into t1
                   select new { ParticipationId = t1.Key, CreateDateTime = t1.Max() };

var cases = from c in context.Cases
            group c.Create_Date_Time by c.Participation_Id
                into c1
            select new { ParticipationId = c1.Key, CreateDateTime = c1.Max() };

var interactions = from i in context.Interactions
                   join pp in context.Party_Participation on i.Party_Id equals pp.Party_Id
                   group i.Last_Update_Date_Time.HasValue ? i.Last_Update_Date_Time : i.Create_Date_Time
                       by pp.Participation_Id
                       into i1
                   select new { ParticipationId = i1.Key, CreateDateTime = i1.Max() };

transactions.Union(cases);

However at last when I was trying to add third output,

transactions.Union(interactions);
// or
interactions.Union(transactions);

I got the following error

either way it is throwing following error

Error 1 Instance argument: cannot convert from ‘System.Collections.Generic.List<AnonymousType#1>’ to ‘System.Linq.IQueryable<AnonymousType#2>’
Error 2 ‘System.Collections.Generic.List<AnonymousType#1>’ does not contain a definition for ‘Union’ and the best extension method overload ‘System.Linq.Queryable.Union<TSource>(System.Linq.IQueryable<TSource>, System.Collections.Generic.IEnumerable<TSource>)’ has some invalid arguments

The only difference in third sequence is, I am using join with another table. I have tried .AsEnumerable(), .ToList() and .ToArray(), none of them helped.

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

    When you create interactions, its type is not an anonymous type of int and DateTime, it is of int and nullable DateTime. This is because in your inline if statement, you never call .Value off of the nullable column. Your code should work if you create interactions like this:

    var interactions = from i in context.Interactions
                       join pp in context.Party_Participation on i.Party_Id equals pp.Party_Id
                       group i.Last_Update_Date_Time.HasValue ? i.Last_Update_Date_Time.Value : i.Create_Date_Time by
                           pp.Participation_Id
                       into i1
                       select new {ParticipationId = i1.Key, CreateDateTime = i1.Max()};
    

    Simpler Example:

    var lst = new int?[] { 2,3,null,5,5 };
    var lst2 = new int[] { 2,3,4,5,6 };
    
    lst.Select(x => x.HasValue ? x.Value : 0).Union(lst2); //works fine
    lst.Select(x => x.HasValue ? x : 0).Union(lst2); //throws error
    lst.Select(x => x ?? 0).Union(lst2); //also works
    

    Even though we can easily see that the inline if statement will never return a null value in either case, the compiler cannot make such guarantees and has to type the return value to that of a nullable int in the second case.

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

Sidebar

Related Questions

I have managed to get my click event working with the following code. When
I have finally managed to get javan-whenever gem working on my site5 server, and
With more than a little help from daviderossi.blogspot.com I have managed to get some
Thanks to StackOverflow, I managed to get the following code working perfectly, but I
I have managed to get a cron job to run a rake task by
Ok so I have managed to get the format of the date presented in
So far I have managed to get the background image to stretch: XHTML: <div
I am building a client's site in WP and have managed to get the
I am learning basics of EJB 3.0. I have managed to get a sample
I'm writing a MVC website and using jqGrid. I have managed to get it

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.