首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否可以将ADO.NET数据服务与LINQ-to-DataSet数据源一起使用?

是否可以将ADO.NET数据服务与LINQ-to-DataSet数据源一起使用?
EN

Stack Overflow用户
提问于 2009-10-28 01:12:23
回答 1查看 954关注 0票数 0

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

代码语言:javascript
复制
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();
                }
            }
        }
    }
}
}

我得到了错误:

代码语言:javascript
复制
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属性来修饰对象,但我不认为有任何方法可以让我这样做。

你有什么建议吗?我该怎么做呢?我觉得这应该是可能的.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-10-28 01:16:22

我怀疑DataSet是否会有足够强大的元数据来发挥作用,你需要类。我做了几个pots (starting here),让它与LINQ-to-SQL一起工作,你可能会发现它们很有用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1632316

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档