ストアド プロシージャと型指定されていない DataSet に大きく依存する既存のアプリケーションがあります。私はその柔軟性を維持したいと考えていますが、ADO.NET Data Services の REST 機能を活用したいと考えています。ただし、次のコードを使用して DataSet を 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();
}
}
}
}
}
}
エラーが発生します:
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.'.
ここで、ADO.NET Data ServicesがオブジェクトをDataServiceKey属性で装飾することを望んでいることがわかりましたが、とにかくそれを行う必要はないと思います。
これを機能させる方法についてのアイデアはありますか? 出来るはず…って感じです。