【发布时间】:2019-02-23 01:43:33
【问题描述】:
好时光
我有三层 UI,BLL,DAL。
我添加了一个 WEB API 层。我还有一个名为 PersonController 的类,我将它添加到 WEB API 项目中。班级是:
public class PersonController : ApiController
{
public IEnumerable<CommonPerson> GetAllPersons()
{
PersonRepository PersonRep = new PersonRepository();
return PersonRep.SelectAll();
}
}
在 GetAllPersons 操作中,PersonRepository 类被调用,并在数据库查询中从 DbContext 转到 DAL。 这样做的问题是在DAL中无法读取,可以读取连接字符串,会出错。
如何将 web api 与 dal 层连接起来?
【问题讨论】:
-
这部分我没看懂:问题是在DAL中无法读取,可以读取连接字符串,报错。请澄清更多。
标签: asp.net-web-api2