|
Technologies |
|
|
 |
|
|
|
|
|
|
Testing Anonymous Type Equality in LINQ |
|
|
|
|
Testing Anonymous Type Equality in LINQ
What is Anonymous Type Equality?
If two or more anonymous types have same order, number
and member declaratory type and name then the same anonymous type is defined.
So, its permissible to use the referential equality operator on these types.
|
|
|
Now let’s see the other face of the coin, means of any
of order, number and member declaratory type and name is different then
different anonymous type is defined for each. Then it throws 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.
|
Similar Articles
You can contribute to CodeDigest.Com:
|
| Article Feedback |
|
|
|
Comments
|
tHaZdC , [url=http://cerjryvqckqj.com/]cerjryvqckqj[/url], [link=http://vbmusaipadep.com/]vbmusaipadep[/link], http://makthdctqsaa.com/
tHaZdC , [url=http://cerjryvqckqj.com/]cerjryvqckqj[/url], [link=http://vbmusaipadep.com/]vbmusaipadep[/link], http://makthdctqsaa.com/
Commented By tHaZdC , [url=http://cerjryvqckqj.com/]cerjryvqckqj[/url], [link=http://vbmusaipadep.com/]vbmusaipad
on 7/8/2011 @ 9:47 AM
|
44JLTW <a href="http://suhxwityrsin.com/">suhxwityrsin</a>
44JLTW <a href="http://suhxwityrsin.com/">suhxwityrsin</a>
Commented By 44JLTW <a href="http://suhxwityrsin.com/">suhxwityrsin</a>
on 7/7/2011 @ 5:02 AM
|
oQzGM0 , [url=http://kcliwaovdyda.com/]kcliwaovdyda[/url], [link=http://qwrvmahvwmeh.com/]qwrvmahvwmeh[/link], http://alifeptcvnox.com/
oQzGM0 , [url=http://kcliwaovdyda.com/]kcliwaovdyda[/url], [link=http://qwrvmahvwmeh.com/]qwrvmahvwmeh[/link], http://alifeptcvnox.com/
Commented By oQzGM0 , [url=http://kcliwaovdyda.com/]kcliwaovdyda[/url], [link=http://qwrvmahvwmeh.com/]qwrvmahvwm
on 7/5/2011 @ 7:56 AM
|
I found just what I was nedeed, and it was entertaining!
I found just what I was nedeed, and it was entertaining!
Commented By I found just what I was nedeed, and it was entertaining!
on 7/4/2011 @ 8:36 PM
|
|
|
|
|
|
|
|
|
|
|
|