Pregunta

Tenemos una aplicación existente que se basa en gran medida en procedimientos almacenados y conjuntos de datos sin tipo. Me gustaría mantener esa flexibilidad, pero aprovechar las capacidades REST de ADO.NET Data Services. Sin embargo, cuando intento usar el siguiente código para exponer el DataSet a 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();
                }
            }
        }
    }
}
}

Me sale el 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.'.

Vi aquí que ADO.NET Data Services quiere que decore el objeto con un DataServiceKey , pero no creo que haya que hacer eso de todos modos.

¿Alguna idea sobre cómo podría hacer que esto funcione? Siento que debería ser posible ...

¿Fue útil?

Solución

Dudo que DataSet vaya a tener metadatos lo suficientemente fuertes como para ser útiles, y necesitará clases. Hice algunas macetas (comenzando aquí ) para que funcione con LINQ-to-SQL que pueda resultarle útil.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top