2012-04-12 4 views
1

次のチュートリアルhttp://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-applicationを使用してリポジトリを作成しようとしていますが、これらの2つのエラーが発生します。エラーのあるリポジトリを作成していますか?

型または名前空間名は「IShowRepository」が見つかりませんでした(あなたがusingディレクティブまたはアセンブリ参照が不足している?)

メタデータファイル「C:\ユーザーはプロジェクト\ Visual Studioの2010 \ベン\ドキュメント\ \ StudentTheatreGroupWebsite \ StudentTheatreGroupWebsite \ binに\ StudentTheatreGroupWebsite.dll」すべてのヘルプははるかに高く評価されるだろうStudentTheatreGroupWebsite.Tests

見つかりませんでした...

using System; 
using System.Collections.Generic 
using System.Data; 
using System.Linq; 
using StudentTheatreGroupWebsite.Models; 

namespace StudentTheatreGroupWebsite.DAL 
{ 
    public class ShowRepository : IShowRepository , IDisposable 
    { 
     private StudentTheatreContext context; 

     public ShowRepository(StudentTheatreContext context) 
     { 
      this.context = context; 
     } 

     public IEnumerable<Show> GetShows() 
     { 
      return context.Shows.ToList(); 
     } 

     public Show GetShowByID(int id) 
     { 
      return context.Shows.Find(id); 
     } 

     public void InsertShow(Show show) 
     { 
      context.Shows.Add(show); 
     } 

     public void DeleteShow(int ShowID) 
     { 
      Show show = context.Shows.Find(ShowID); 
      context.Shows.Remove(Shows); 
     } 

     public void UpdateShow(Show show) 
     { 
      context.Entry(show).State = EntityState.Modified; 
     } 

     public void Save() 
     { 
      context.SaveChanges(); 
     } 

     private bool disposed = false; 

     protected virtual void Dispose(bool disposing) 
     { 
      if (!this.disposed) 
      { 
       if (disposing) 
       { 
        context.Dispose(); 
       } 
      } 
      this.disposed = true; 
     } 

     public void Dispose() 
     { 
      Dispose(true); 
      GC.SuppressFinalize(this); 
     } 
    } 
} 
+0

StudentTheatreGroupWebsite.Modelsを使用してIShowRepository ... –

+0

の名前空間を表示できますか。 名前空間StudentTheatreGroupWebsite.DAL { – user1259076

答えて

1

私は版の前に、あなたのコードをコピー:

using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using StudentTheatreGroupWebsite.Models; 

    namespace StudentTheatreGroupWebsite.DAL { 

    public interface IStudentRepository : IDisposable { 
     IEnumerable<Show> GetShows(); 
     Show GetShowByID(int ShowId); 
     void InsertShow(Show Show); 
     void DeleteShow(int ShowID); 
     void UpdateShow(Show Show); 
     void Save(); 
    } 
} 

IStudentRepositoryではなく、「IShowRepository」と呼びますか?

+0

ありがとう私の間違い、今集中していないことのおかげで:) – user1259076

+0

正解ですので – user1259076

関連する問題