Converting SQL to LINQ to XML

Posted by Morano88 on Stack Overflow See other posts from Stack Overflow or by Morano88
Published on 2010-04-16T21:47:28Z Indexed on 2010/04/16 21:53 UTC
Read the original article Hit count: 302

Filed under:
|
|
|

I'm writing the following code to convert SQL to LINQ and then to XML:

SqlConnection thisConnection = new SqlConnection(@"Data Source=3BDALLAH-PC;Initial Catalog=XMLC;Integrated Security=True;Pooling=False;");
thisConnection.Open();

XElement eventsGive =
    new XElement("data",
        from c in ?????? 
        select new XElement("event",
            new XAttribute("start", c.start),
            new XAttribute("end",c.eend),
            new XAttribute("title",c.title),
            new XAttribute("Color",c.Color),
            new XAttribute("link",c.link)));

Console.WriteLine(eventsGive);

The name of the table is "XMLC" and I want to refer to it. How can I do that? When I put its name directly VS gives an error. Also when I say thisConnection.XMLC it doesn't work.

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql-to-linq