C# Tutorials and offshore development in India
Tutorials Resources Forum Reviews Communities Interview Jobs Projects Training Videos


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...


Birthday Greetings
Learn Windows 7: How to modify Windows Vista/7 AutoPlay settings   This article explains how to modify the Autoplay setting in Windows Vista and Windows 7, by modifying the Autoplay settings you can change the default behavior of the media type to open the media in respective software



Resources » Articles » .NET Framework »

How to Test Anonymous Type Equality - LINQ: A Step Ahead Series


Posted Date: 09 Feb 2009    Resource Type: Articles    Category: .NET Framework
Author: Gaurav AroraMember Level: Diamond    
Rating: 5 out of 55 out of 55 out of 55 out of 55 out of 5Points: 20 (Rs 20)



How to Test Anonymous Type Equality - LINQ: A Step Ahead Series

First of all Anonymous Type Equality : If two or more anonymous types have same order, number and member declaratory type amd name then the same anonymous type is defined. So, its permissible to use the referencial equality operator on these types.

Now lets see the other face of the coin means of any of order, number and member declarator type and name is different then different anonymous type is defined for each. Then it throw compiler error while testing referential integrity.

Note:

  • Here you can use reflection to get the type information of anonymous types.

  • Use the Equals method (defined by all objects) to test equality of members.



Lets go through following lines :

var paternalMember = new {Father = "R k Arora", City = "Nangal Dam"};
var maternalMember = new {Mother = "Santosh Arora", City = "New Delhi"};

var fatherHome = new {Father = "R k Arora", City = "Nangal Dam"};
var motherHome = new {City = "New Delhi", Mother = "Santosh Arora"};

//Compare member equality:
paternalMember.Equals(fatherHome); //returns true
paternalMember.Equals(fatherHome); //error



If you want to know more about Anonymous Type-LINQ please refer to Anonymous Types in LINQ : A Step Ahead Series





Responses to the resource: "How to Test Anonymous Type Equality - LINQ: A Step Ahead Series"

No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
LINQ  .  How to Test Anonymous Type Equality - LinQ : A Step Ahead Series  .  Anonymous Types  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Polymorphism
Previous Resource: Encrypting Sections in Web.config File
Return to Resources
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



About Us    Contact Us    Privacy Policy    Terms Of Use