Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do not use <code>Value</code> property to get value of attribute or element. If node is missing, you will get exception. When you casting node (e.g. to string), you will get default value for that type if node is missing. Also you can use <code>??</code> operator to provide your own default value for missing string nodes (by default you will get null).</p> <pre><code>result = (string)column.Element("dataType") ?? String.Empty </code></pre> <p>Same trick used with boolean values - I get <code>Nullable&lt;bool&gt;</code> and if it's <code>null</code> (node missing) then I assign <code>false</code> if it is not <code>null</code>, then node's value successfully assigned to non-nullable property:</p> <pre><code> ListOfForms = (from form in doc3.Descendants("form") select new ScanBandForm() { FormTypes = (string)form.Attribute("types"), ScanBandNumber = (string)form.Attribute("number"), ListOfRows = (from row in form.Descendants("row") select new ScanBandRow() { AllowSpaces = (bool?)row.Element("allowSpaces") ?? false, SplitCharacter = (string)row.Element("splitCharacter"), ListOfColumns = (from column in row.Descendants("column") select new ScanBandColumn() { AlwaysKey = (bool?)column.Element("allwaysKey") ?? false, DataTypeString = (string)column.Element("dataType") ?? String.Empty, MatchingFieldName = (string)column.Element("matchingFieldName") ?? String.Empty, NonField = (bool?)column.Element("nonField") ?? false, RegularExpressionString = (string)column.Element("regularExpression") ?? String.Empty, }).ToList() }).ToList() }).ToList(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload