score:1

Accepted answer

It sounds like you want to use Linq-to-Sql. In that case you'll need to create a data context. There are plenty of tutorials on that.

You don't need to use linq to sql, however. Your source can be any enumerable. A DataReader, for example:

using (DbDataReader rdr = cmd.ExecuteReader()) {


    from c in rdr.Cast<DbDataRecord>() 
    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"])));

}

Related Articles