dotnetspider.com


 


TutorialsForumResourcesReviewsJobsInterviewVideosCommunitiesProjectsTraining

Subscribe to Subscribers


Online MembersSunitha
Prasad kulkarni
Prabu Thangavelu
chaminda
sravan
cloud
Shesh Kumar Mishra
Gajanan
pavan
Anu George
somasekar
More...




Resources » Articles » .NET Framework


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


Posted Date:     Category: .NET Framework    Rating: 5 out of 55 out of 55 out of 55 out of 55 out of 5
Author: Member Level: Gold    Points: 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


Did you like this resource? Share it with your friends and show your love!





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

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    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
    Popular Tags   Tag posting guidelines   Search Tags  
    LINQ  .  How to Test Anonymous Type Equality - LinQ : A Step Ahead Series  .  Anonymous Types  .  

    My Profile

    Active Members
    TodayLast 7 Daysmore...


    Awards & Gifts


    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds



    About Us    Trademark Disclaimer    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.