Note that there are some explanatory texts on larger screens.

plurals
  1. POLinq - Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement>' to 'System.Collections.Generic.List<string>'
    primarykey
    data
    text
    <p>I am getting the following error:</p> <blockquote> <p>Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'System.Collections.Generic.List'. An explicit conversion exists (are you missing a cast?)</p> </blockquote> <p>My code is as follows : </p> <pre><code> public Profile PullActiveProfile() { //currentProfile.Decks = new List&lt;string&gt;(); return currentProfile = (from profiles in xmlDoc.Element("PlayerPofiles").Elements("Player")where (string)profiles.Element("Active") == "True" select new Profile { Name = (string)profiles.Element("Name"), Type = (string)profiles.Element("Type"), Verified = (string)profiles.Element("Verified"), Password = (string)profiles.Element("Password"), Email = (string)profiles.Element("Email"), Sex = (string)profiles.Element("Sex"), Avatar = (string)profiles.Element("Avatar").Attribute("path") ?? "", Created = (DateTime)profiles.Element("Created"), Birthday = (string)profiles.Element("Birthday") ?? "", Wins = (string)profiles.Element("Ratio").Element("Win") ?? "0", Losses = (string)profiles.Element("Ratio").Element("Loss") ?? "0", Abandoned = (string)profiles.Element("Ratio").Element("Abandoned"), // The following line is where I get the error. The decks node can have many descendants Decks = profiles.Elements("Decks").Descendants() .Select(x =&gt; x.ToString()).ToList(); }).FirstOrDefault(); } </code></pre> <p>Here is the node structure:</p> <pre><code>&lt;PlayerPofiles&gt; &lt;Player&gt; &lt;Name&gt;Stacey - Online&lt;/Name&gt; &lt;Type&gt;Full/Basic&lt;/Type&gt; &lt;Active&gt;True&lt;/Active&gt; &lt;Verified&gt;True&lt;/Verified&gt; &lt;Password&gt;pass&lt;/Password&gt; &lt;Email&gt;xxxx@gmail.com&lt;/Email&gt; &lt;Sex&gt;Female&lt;/Sex&gt; &lt;Avatar path="/images/Treasure/BroadSword.png" /&gt; &lt;Ratio&gt; &lt;Win&gt;0&lt;/Win&gt; &lt;Loss&gt;0&lt;/Loss&gt; &lt;Abandoned&gt;0&lt;/Abandoned&gt; &lt;/Ratio&gt; &lt;Created&gt;6/19/2011&lt;/Created&gt; &lt;Birthday&gt;09/28/1989&lt;/Birthday&gt; &lt;Decks&gt; &lt;Base /&gt; &lt;Booty /&gt; &lt;/Decks&gt; &lt;/Player&gt; </code></pre> <p></p>
    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.
 

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