Try our conversational search powered by Generative AI!

LINQ with page creteria

Vote:
 

Hi,

I have two  criteria in my code 

 

 

var systemPages = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criteria);

var pages = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criterias);

I want the pages  from  criteria system pages  which is not in  criteria pages

I am using LINQ

 

 

var matches = (pages.Intersect(systemPages));

but i am getting nothing. Please tell is there any way to get the pages from pages which is not in systemPages

#46141
Nov 30, 2010 6:54
Vote:
 

If you want the pages in A that are not also in B, you should use Except, not Intersect. If that isn't working I'm guessing the default comparer isn't behaving you want it to (comparing page id, version and language for example). In that case you'd have to try the overload which takes an IEqualityComparer do to the job. Tip: Google AnonymousComparer and LambdaComparer to find inspiration on how to build a comparer that accepts a lambda expression to compare by.

Good luck!
/Magnus

#46142
Nov 30, 2010 7:53
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.