简体   繁体   English

谁能帮助我我对下面的这条消息有疑问

[英]can anyone help me i have problem with this message below

namespace EmployeeService.Controllers
{
    public class EmployeeController : ApiController
    {
        public IEnumerable<Customer> Get()
        {
            using (Test_DBEntities test = new Test_DBEntities())
            {
                return test.Customers.tolist();
            }
        }
    }
}

Note: EmployeeDataAccess.Test_DBEntities : type used in a using statement must be implicitly convertible to System.IDisposable .注意: EmployeeDataAccess.Test_DBEntities :在using语句中使用的类型必须隐式转换为System.IDisposable

Your Test_DBEntities does not implement the System.IDisposable so you cannot put it in the using statement, remove it and the error will be gone.你的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();
       }
   }
}

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

相关问题 谁能帮我这个? 在客户端部分刷新更新面板 - Can Anyone Help me with this? Refresh update panel partially onclient side 谁能帮我解决这个数据库查询错误? - Can anyone help me resolve this db query error? 能帮我看看真正的问题是什么? - Can help me to see what is the real problem? 我无法将面板的可见属性(1到6)从false更改为true,它们包含在loginview中,谁能帮助我 - I cant get the visible properties of my panel ( 1 to 6 ) to change from false to true, they are contained within a loginview , can anyone help me 谁能帮我弄清楚为什么我的注册表不会提交到我的数据库? - Can anyone help me figure out why my registration form will not submit to my database? 谁能帮我在GridView中以完全相同的格式查看文本框(多行文本模式) - Can anyone help me view textbox (multi-line textmode) in gridview with exactly the same format IIS7间歇性地抛出500错误。 任何人都可以帮我诊断吗? - IIS7 is throwing a 500 error intermittently. Can anyone help me diagnose it? Net5.0 Razor 页面 CRUD 删除错误,谁能帮我解决这个问题? - Net5.0 Razor Pages CRUD Delete Error, Can anyone help me with this? 我们该如何在代码下编写单元测试? - How can we write Unit Test below Code?Can any one help me in this one 任何人都可以向我解释 CreatedAtRoute() 吗? - Can anyone explain CreatedAtRoute() to me?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM