有人可以帮助我吗?我对下面的这条消息有疑问

问题描述 投票:0回答:1
namespace EmployeeService.Controllers
{
    public class EmployeeController : ApiController
    {
        public IEnumerable<Customer> Get()
        {
            using (Test_DBEntities test = new Test_DBEntities())
            {
                return test.Customers.tolist();
            }
        }
    }
}

注意:

EmployeeDataAccess.Test_DBEntities
using
语句中使用的类型必须可以隐式转换为
System.IDisposable

asp.net
1个回答
0
投票

你的

Test_DBEntities
没有实现
System.IDisposable
所以你不能把它放在using语句中,删除它,错误就会消失。

namespace EmployeeService.Controllers {
   public class EmployeeController: ApiController {
       public IEnumerable Get() {
           Test_DBEntities test = new Test_DBEntities();
           return test.Customers.tolist();
       }
   }
}
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.