0

我们有一个严重依赖存储过程和无类型数据集的现有应用程序。我想保持这种灵活性,但要利用 ADO.NET 数据服务的 REST 功能。但是,当我尝试使用以下代码将 DataSet 公开给 ADO.NET 数据服务时:

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 数据服务希望我使用DataServiceKey属性来装饰对象,但我认为无论如何我都不会这样做。

关于如何让这个工作的任何想法?我觉得应该可以。。。

4

1 回答 1

0

我怀疑这DataSet是否会有足够强大的元数据有用,并且您将需要类。我做了一些尝试(从这里开始)让它与 LINQ-to-SQL 一起工作,您可能会觉得它们很有用。

于 2009-10-27T17:16:22.130 回答