我们有一个现有的应用程序,它严重依赖于存储过程和非类型化DataSets。我希望保持这种灵活性,但要利用ADO.NET数据服务的REST功能。但是,当我尝试使用以下代码向ADO.NET数据服务公开DataSet时:
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.'.我看到here说ADO.NET数据服务希望我用DataServiceKey属性来修饰对象,但我不认为有任何方法可以让我这样做。
你有什么建议吗?我该怎么做呢?我觉得这应该是可能的.
发布于 2009-10-28 01:16:22
我怀疑DataSet是否会有足够强大的元数据来发挥作用,你需要类。我做了几个pots (starting here),让它与LINQ-to-SQL一起工作,你可能会发现它们很有用。
https://stackoverflow.com/questions/1632316
复制相似问题