LINQ

LINQ to XML on assembly embedded XML files

LINQ to XML rocks. I use it pretty much day in day out to read mock up data from XML files for prototyping. Today I needed a way to work with an XML file that was embedded in an assembly as an Embedded Resource. Following are the contents of the file: <Users> <User ID="1" Name="Jim"/> <User ID="1" Name="Jon"/> <User ID="1" Name="jack"/> <User ID="1" Name="Matt"/> </Users> LINQ to XML makes working with this very easy. public static XDocument GetDocument(string ......

Object equality in Except and other set operators in LINQ

Here is an interesting issue I noticed when using the Except extension method. I have list of users from which I want to exclude some users: The list of users is coming from an XML file: <Users> <User id="1" name="Jack"/> <User id="2" name="Jim"/> <User id="3" name="Joe"/> <User id="4" name="James"/> <User id="5" name="Tom"/> <User id="6" name="Matt"/> <User id="7" name="Jon"/> <User id="8" name="Jill"/> </Users> The code goes like this: ......