2
리포지토리 생성을 돕기 위해 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 을 지침으로 사용했습니다. 아래 코드로 클래스를 만들었습니다.리포지토리 생성
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TheatreGroup.Models;
namespace TheatreGroup.DAL
{
public interface IShowRepository : IDisposable
{
IEnumerable<Show> GetShows();
Show GetShowByID(int showId);
void InsertShow(Show name);
void DeleteShow(int showID);
void UpdateShow(Show name);
void Save();
}
}
하지만 난이 두 번째 클래스를 만드는 올 때 내가 말하는 오류 얻을 : (TheatreGroup TheatreGroup.DAL.IShowRepository.InsertShow '인터페이스 멤버를 구현하지 않습니다'
TheatreGroup.DAL.ShowRepository합니다. 모델. 쇼) '.
오류 당신은 InsertShows
하지 InsertShow
이 (약 라운드)
using System.Data;
using TheatreGroup.Models;
namespace TheatreGroup.DAL
{
public class ShowRepository: IShowRepository, IDisposable
{
private TheatreContext context;
public ShowRepository(TheatreContext context)
{
this.context = context;
}
public IEnumerable<Show> GetShows()
{
return context.Shows.ToList();
}
public Show GetShowByID(int id)
{
return context.Shows.Find(id);
}
public void InsertShows(Show name)
{
context.Shows.Add(name);
}
public void DeleteShow(int showID)
{
Show shows = context.Shows.Find(showID);
context.Shows.Remove(shows);
}
public void UpdateShow(Show name)
{
context.Entry(name).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);
}
}
}
+1 쌍 프로그래밍 LOL의 이점에 대한 포스터 질문입니다. –