EDN Admin
Well-known member
My LINQ statement looks like
<pre class="prettyprint List<XElement> filteredset = (from file in matchingsets.Elements<XElement>(Global.xnFile) where (((string)file.Attribute(Global.xnToKeep).Value != "*")
&& ((string)file.Attribute(Global.xnProtected).Value != "*") & & File.Exists(file.Attribute(Global.xnPath).Value)) select file).ToList<XElement>(); [/code]
My problem is that neither file.Attribute(Global.xnToKeep). nor file.Attribute(Global.xnProtected) are guaranteed to exist in file. So, I need to test their existence before testing what their value is. How do I do that in a LINQ statement?<br/>
View the full article
<pre class="prettyprint List<XElement> filteredset = (from file in matchingsets.Elements<XElement>(Global.xnFile) where (((string)file.Attribute(Global.xnToKeep).Value != "*")
&& ((string)file.Attribute(Global.xnProtected).Value != "*") & & File.Exists(file.Attribute(Global.xnPath).Value)) select file).ToList<XElement>(); [/code]
My problem is that neither file.Attribute(Global.xnToKeep). nor file.Attribute(Global.xnProtected) are guaranteed to exist in file. So, I need to test their existence before testing what their value is. How do I do that in a LINQ statement?<br/>
View the full article