LINQ To Dataset : can't use Take() on a query RRS feed

  • Question

  • Hi,

    I've got a Dataset filled with an SqlDataAdapter, which stores the result of a SQL Server stored proc.
    I want to create a XML file with the 25 first results of this Dataset, so I wrote this code :

    var element = (from topic in ds.Tables[0].AsEnumerable()
                             select new XElement("topic",
                                                        new XAttribute("id", topic.Field<int>("R_t_id")),
                                                        new XAttribute("nbanswers", topic.Field<int>("c")),

    But it doesn't work : the error I get is the following

    System.Data.EnumerableRowCollection<System.Xml.Linq.XElement>' does not contain a definition for 'Take' and no extension method 'Take' accepting a first argument of type 'System.Data.EnumerableRowCollection<System.Xml.Linq.XElement>' could be found (are you missing a using directive or an assembly reference?)

    I don't understand, because EnumerableRowCollection implements IEnumerable interface, so the method 'Take' should be present...

    Any idea ?
    Thanks in advance
    Tuesday, February 3, 2009 12:20 PM