简体   繁体   English

ADO.NET数据服务和自定义数据源

[英]ADO.NET Data Services and Custom Data Source

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. 我过去有一个用于WinForms,WebForms和ASP.NET MVC项目的业务逻辑层(BLL)和数据访问层(DAL)。 The objects implement all kinds of interfaces. 对象实现各种接口。 Now I would like to tackle ADO.NET Data Services. 现在,我想谈谈ADO.NET数据服务。

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? 我有什么我没有添加的BLL? Am I too naive to think it'll just "work", but Astoria being quite complex? 我是否天真地以为它只会“起作用”,但是Astoria非常复杂?

public class EmployeeData
    {
        private static EmployeeCollection employees;

        public EmployeeData()
        {
            employees = EmployeeLoaded.GetData();
        }

        public IQueryable<Employee> Employees
        {
            get
            {
                return employees.AsQueryable();
            }
        }
   }

Your entities need to have their attributes like DataServiceKey setup like the exmple below. 您的实体需要具有其属性,例如DataServiceKey设置,例如下面的示例。

[DataServicesKey("Id")]
public partial class Customer
{
}

And if you are looking to write data using your BLL, your model will need to implement the IUpdatable interface. 而且,如果您希望使用BLL写入数据,则您的模型将需要实现IUpdatable接口。

您还需要在InitializeService方法中调用config.SetEntitySetAccessRule以启用对实体集(员工)的访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM