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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:19:38+00:00 2026-06-15T16:19:38+00:00

I am trying to find a method to compare the element inside LINQ result

  • 0

I am trying to find a method to compare the element inside LINQ result

This is the LINQ code

var sets =
         from a in patient.AsParallel()
         from b in patient.AsParallel()
         from c in patient.AsParallel()
         from d in patient.AsParallel()



where a.VisitNum < b.VisitNum && b.VisitNum < c.VisitNum && c.VisitNum < d.VisitNum
select new { a, b, c, d };

var sets1 =
                 from a in patient1.AsParallel()
                 from b in patient1.AsParallel()
                 from c in patient1.AsParallel()
                 from d in patient1.AsParallel()
select new { a, b, c, d };

and this code I used it to compare but every time give me false

 if (Enumerable.SequenceEqual(sets, sets1) == true)

Any suggestion ?

// update as Jani’s Answer

public class Result
    {
        public ACVsize5 a { get; set; }
        public ACVsize5 b { get; set; }
        public ACVsize5 c { get; set; }
        public ACVsize5 d { get; set; }


}

public override Boolean Equals(Result other)
        {
            return other.a.date.ToString() == a.date.ToString() && other.a.RaId.ToString() == a.RaId.ToString() && other.b.date.ToString() == b.date.ToString() && other.b.RaId.ToString() == b.RaId.ToString() && other.c.date.ToString() == c.date.ToString() && other.c.RaId.ToString() == c.RaId.ToString() && other.d.date.ToString() == d.date.ToString() && other.d.RaId.ToString() == d.RaId.ToString();
        }

var sets =
             from a in patient
             from b in patient
             from c in patient
             from d in patient
where a.VisitNum < b.VisitNum && b.VisitNum < c.VisitNum && c.VisitNum < d.VisitNum              

select new Result { a = a, b = b, c = c, d = d };
var sets1 =
             from t in patient1
             from y in patient1
             from u in patient1
             from p in patient1
where t.VisitNum < y.VisitNum && y.VisitNum < u.VisitNum && u.VisitNum < p.VisitNum 
             select new Result { a = t, b = y, c = u, d = p };

but I got error on override methods

//Error 1 no suitable method found to override
  • 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-15T16:19:40+00:00Added an answer on June 15, 2026 at 4:19 pm

    Actully you are trying to compare two different anonymous classes which has been generated under the hood (System.Linq.ParallelQuery<AnonymousType#1>' and 'System.Linq.IQueryable<AnonymousType#2>').

    I was wrong and as stated by @Allon, there will be generated just one class for the same structure.

    Whenever you use the select new in a Linq query without specifying the class name before open bracket, an anonymous class will be generated under the hood which you can see it by tools like ILDasm or Reflector.

    Another important point is that when you compare objects of a type which you declared(not part of .NET Framework Library), they will be compared by their references not by their content.
    Thus you must define your own implementation of equality, by overriding the Equals method.

    That’s not the case for anonymous classes cause the compiler will generate those methods for them.

    To learn more:
    1,
    2

    Create a simple class (named result for example) and make the result of query of that type.
    Then override the Equals method of the class and use the SequenceEqual.
    everything will be right.

    public Class Result{
      public string a {get;set}
      public string b {get;set}
      public string c {get;set}
      public string d {get;set}
      //this is a short incomplete version of equals implementation
      //consult other questions to learn more about equality
      public override boolean Equals(Result other)
      { return other.a == a && other.b == b && other.c == c && other.d == d}
    }
    
    //you must add another order by clause to query so that both of them have the same order
    var sets =
         (from a in patient.AsParallel()
         from b in patient.AsParallel()
         from c in patient.AsParallel()
         from d in patient.AsParallel()
         where a.VisitNum < b.VisitNum && b.VisitNum < c.VisitNum && c.VisitNum < d.VisitNum
         select new Result{ a = a, b = b, c = c, d = d }).AsEnumerable();
    var sets1 =
         (from a in patient1.AsParallel()
         from b in patient1.AsParallel()
         from c in patient1.AsParallel()
         from d in patient1.AsParallel()
         select new Result{ a = a, b = b, c = c, d = d }).AsEnumerable();
    //Now it would be right
    if (Enumerable.SequenceEqual(sets, sets1))
    {
       //do your stuff
    }
    

    You just need to ensure that those sequences have the same order.

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

Sidebar

Related Questions

I'm trying to find the jQuery equivalent of this JavaScript method call: document.addEventListener('click', select_element,
Trying to find a good name for a method swapping each coordinate X and
I'm trying to implement method Find that searches the database. I forgot to mention
I'm trying to write (or just find an existing) PHP method that can take
I am trying in C language to use the method of bisection to find
I am tring this method to find the common characters in two strings namely,
Trying to find a way to remove blank pages from a document I wrote
I am trying to compare two NSDates one is created by the viewDidLoad method
Ok, I'm trying to get this working. This is my first time using LINQ.
I am trying to find a method to rollback a transaction after it has

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.