ADO.NET 数据服务和自定义数据源
我有一个业务逻辑层 (BLL) 和一个数据访问层 (DAL),过去用于 WinForms、WebForms 和 ASP.NET MVC 项目。这些对象实现了各种接口。现在我想解决 ADO.NET 数据服务问题。
我正在尝试类似以下的简单操作,但它没有提供我的服务。我完全错过了什么吗?我的 BLL 中添加了哪些我没有添加的内容?我是否太天真地认为它会“起作用”,但阿斯托里亚相当复杂?
public class EmployeeData
{
private static EmployeeCollection employees;
public EmployeeData()
{
employees = EmployeeLoaded.GetData();
}
public IQueryable<Employee> Employees
{
get
{
return employees.AsQueryable();
}
}
}
I have a Business Logic Layer (BLL) and a Data Access Layer (DAL) that used for WinForms, WebForms, and ASP.NET MVC projects in the past. The objects implement all kinds of interfaces. Now I would like to tackle ADO.NET Data Services.
I am trying something simple like the following, but it's not rendering my service. Am I totally missing something? What do I have add to my BLL that I haven't? Am I too naive to think it'll just "work", but Astoria being quite complex?
public class EmployeeData
{
private static EmployeeCollection employees;
public EmployeeData()
{
employees = EmployeeLoaded.GetData();
}
public IQueryable<Employee> Employees
{
get
{
return employees.AsQueryable();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的实体需要具有其属性,例如 DataServiceKey 设置,如下例所示。
如果您希望使用 BLL 写入数据,您的模型将需要实现 IUpdatable 接口。
Your entities need to have their attributes like DataServiceKey setup like the exmple below.
And if you are looking to write data using your BLL, your model will need to implement the IUpdatable interface.
您还需要在 InitializeService 方法中调用 config.SetEntitySetAccessRule 以启用对实体集(员工)的访问。
You will also need a call to config.SetEntitySetAccessRule in your InitializeService method to enable access to your entity set (Employees).