views:

347

answers:

1

We have an existing application that relies heavily on stored procedures and untyped DataSets. I'd like to maintain that flexibility, but leverage the REST capabilities of ADO.NET Data Services. However, when I attempt to use the following code to expose the DataSet to ADO.NET Data Services:

namespace NewTechnologyDemo {
public class MyDataSource {
    public IQueryable<DataRow> TheDataSet {
        get {
            using (SqlConnection connection = new SqlConnection("server=MySQLServer;integrated security=sspi;database=MyDatabase")) {
                using (SqlCommand command = new SqlCommand("select * from Orders", connection)) {
                    SqlDataAdapter adapter = new SqlDataAdapter(command);
                    DataSet ds = new DataSet();
                    adapter.Fill(ds);

                    return ds.Tables[0].AsEnumerable().AsQueryable();
                }
            }
        }
    }
}
}

I get the error:

The server encountered an error processing the request. The exception message is 'On 
data context type 'MyDataSource', there is a top IQueryable property 'TheDataSet' whose 
element type is not an entity type. Make sure that the IQueryable property is of entity 
type or specify the IgnoreProperties attribute on the data context type to ignore this 
property.'.

I saw here that ADO.NET Data Services wants me to decorate the object with a DataServiceKey attribute, but I don't think there's anyway for me to do that.

Any ideas on how I could get this working? I feel like it should be possible...

A: 

I doubt that DataSet is going to have anywhere near strong enough metadata to be useful, and you'll need classes. I did a few pots (starting here) on getting it working with LINQ-to-SQL that you might find useful.

Marc Gravell
Yeah, I looked that over before posting. I'm beginning to see your point about "needing classes." Otherwise, the properties of the *DataRow* are going to get serialized, instead of the contents of the Item property, which is what I really want.
GuyBehindtheGuy

related questions