2011-09-12 4 views
-3

내 애플리케이션을 시작하는 방법과 시작 위치를 알지 못합니다. 이러한 기술의 샘플 애플리케이션을 가지고 계시다면 공유하거나 (내) 친절하게 내 애플리케이션을 시작하라고 안내해주십시오. 내 기술 Framework 3.5와 언어는 C#이고 템플릿은 MVC2가 될 것이고 백엔드는 oracle 9i가 될 것입니다. 이미 데이터베이스가 있습니다 & 테이블.오라클 데이터베이스가 포함 된 mvc2

답변

2

ASP.NET MVC를 특정 데이터 액세스 기술과 믹싱하지 않아야합니다. DAL 레이어로 추출해야합니다.

public interface IProductsRepository 
{ 
    Product Get(int id); 
} 

다음 컨트롤러 : 예를 들어 모든 그런

public class ProductsRepositoryOracle: IProductsRepository 
{ 
    ... Oracle specific data access code 
    you could either use an ORM such as NHibernate, EF, ... or 
    plain ADO.NET with the ODP.NET provider. It's really an implementation 
    detail that has no impact on the MVC application. 
} 

:

public class ProductsController: Controller 
{ 
    private readonly IProductsRepository _repository; 
    public ProductsController(IProductsRepository repository) 
    { 
     _repository = repository; 
    } 

    public ActionResult Index(int id) 
    { 
     var product = _repository.Get(id); 
     return View(product); 
    } 
} 

는 당신은 Oracle 데이터베이스에 특정 될 것입니다이 제품 저장소의 구현을 가질 수 남아있는 것은 DI 프레임 워크가 Oracle 저장소 구현을 컨트롤러로 전달하도록 구성하는 것입니다.

ASP.NET MVC 응용 프로그램을이 방법으로 사용하면 데이터가있는 곳에서 완전히 분리 될 수 있습니다.

0

나는 Entity Framework 모델을 사용하는 가장 간단한 방법이라고 생각합니다. Darin이 언급 한 필요한 추상화 계층을 추가합니다. Oracle을 기본 데이터베이스 서버로 사용하려면 아직 아무도없는 경우 Entity Framework 공급자를 설치해야 할 수도 있습니다 (http://www.oracle.com/technetwork/topics/dotnet/downloads/oracleefbeta-302521.html 참조).

확인 의심의 여지가 당신을 위해 도움이 될 것입니다 이러한 튜토리얼 : Creating Model Classes with the Entity Framework

관련 문제