2011-04-20 137 views
0

我有以下代码:意外EntityObject错误

public IList<T_CLIENT> Get_All_Obj() 
{ 
    try 
    { 
     IList<T_CLIENT> LesListe; 
     using (FaExpedEntities oEntite_T = new FaExpedEntities()) 
     { 
      var query = from o in oEntite_T.T_CLIENT select o; 
      LesListe = query.ToList(); 
     } 
     return LesListe; 
    } 
    catch (Exception excThrown) 
    { 
     throw new Exception("Err_02", excThrown); 
    } 
} 

但我不知道为什么我得到这些错误:

Error 1 The type 'System.Data.Objects.DataClasses.EntityObject'is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089'. C: \ Soft8 \ FA_Exped \ Code \ FrontEnd \ FaExped_FrontEnd_WebApp_Domaine \ FaExped_FrontEnd_WebApp_Business \ Le_T \ LeTclientusrstatus_Entite_BL.cs 15 42 FaExped_FrontEnd_WebApp_Business 

Error 2 c: \ Soft8 \ FA_Exped \ Code \ FrontEnd \ FaExped_FrontEnd_WebSite \ Login.aspx.cs (8): error CS0246: The type or namespace name 'FaExped_FrontEnd_WebApp_Business' not found (a using directive or a reference to 'assembly is it missing?) 

Error 3 'FaExped_FrontEnd_WebApp_Domaine.FaExpedEntities': type used in a using statement must be implicitly convertible to 'System.IDisposable'C: \ Soft8 \ FA_Exped \ Code \ FrontEnd \ FaExped_FrontEnd_WebApp_Domaine \ FaExped_FrontEnd_WebApp_Business \ Le_T \ LeTclient_Entite_BL.cs 22 17 FaExped_FrontEnd_WebApp_Business 

如何解决这些错误?

+2

这是在您的开发人员机器上还是在另一台机器上?你有没有确保System.Data.Entity在你的bin文件夹中? – 2011-04-20 08:36:26

+0

听起来像你缺少一个参考。 – 2011-04-20 10:13:40

+0

解决方案的结构是什么? EF数据模型(EDMX)是否在另一个项目中,而不是托管上述代码的项目? – 2011-04-20 14:42:14

回答

1

我认为你可以简单地做到这一点,像这样:

var entities = new FaExpedEntities(); 
return entities.T_CLIENT.ToList(); 

请确保您有必要引用和using语句。

希望这有助于:)