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 Query