0

I have the code below:
List<XElement> DBListSetxElements = DbListSetItems[0].Value.Root.Descendants("ListSet").Select(desc => desc.Attribute("Name")).Distinct().ToList();

While compile getting error Error CS0029 Cannot implicitly convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<System.Xml.Linq.XElement>'

Need Help.

1
  • 3
    the error ir pretty straightforward, you're trying to cast a list of strings result from Db into a list of XML elements that cant be done implicitily Commented Apr 4, 2022 at 6:27

1 Answer 1

0

Actually you need to provide the DbListSetItems class definition if you want any more help. Seems you're trying to select the name of the XML element and perhaps in the DbListSetItems data you have the content.

This solution creates a XML Element but the content is null As I said if you want to populate with some other DbListSetItems property you need to provide us some info (or get the apropiate value from it like desc.Attribute("theApropiateAtributeNameValue") ) instead null:

        List<XElement> DBListSetxElements = DbListSetItems[0].Value.Root.Descendants("ListSet")
            .Select(desc => new XElement(desc.Attribute("Name"), null)).Distinct().ToList();
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.