DHJJ DHJJ [Hatsune's Journal Japan]

ASP.NET MVC 3 PreviewでOracleアプリを作ろう

ASP.NET MVC 3 PreviewでOracleアプリを作ろう

01

Oracle Databaseについて

バージョンとEdition

04

Oracleの開発環境を入手

05

Oracleってチューニング大変だよね?

06

開発用途なら有償オプションも無料

07

.NETからOracleに接続するなら.NET付属がいいんじゃ?

08

ASP.NET MVCについて

ASP.NET MVC 2 について

10

ASP.NET MVC 2 - 処理の流れ

11

ASP.NET MVC 2 - プロジェクト構成

12

ASP.NET MVC 2は単体テストがしやすい

13

System.Mvc.HtmlHelper

代表的なメソッド

概要

ActionLink

Aタグを生成

<%: Html.ActionLink("Log On", "LogOn", "Account") %>

<a href="/Account/LogOn">Log On</a>

BeginForm

formタグを生成

<% using (Html.BeginForm()) { %>

<form action="/Account/Register" method="post">

TextBoxFor

INPUTタグを生成

Html.TextBoxFor(m => m.UserName)

<input id="UserName" name="UserName" type="text" value="" />

ASP.NET MVC 3の注目ポイント

ASP.NET MVC 2 + 新機能 = ASP.NET MVC 3 Preview 1

16

ASP.NET MVC 3 Preview 1の注目ポイント

17

Dynamic View and ViewModel Properties

18

View Engine (Razor)

19

JsonValueProviderFactory(ValueProviderFactory)

20

ASP.NET MVC + Oracle

ASP.NET MVC 3 Preview1 + ODP.NET

22

Public Class EmpController
    Inherits System.Web.Mvc.Controller

    Private empServiceValue As IEmpService
    Public Property EmpService() As IEmpService
        Get
            Return empServiceValue
        End Get
        Set(ByVal value As IEmpService)
            empServiceValue = value
        End Set
    End Property
    Protected Overrides Sub Initialize(ByVal requestContext As RequestContext)
        If EmpService Is Nothing Then EmpService = New EmpService()
        MyBase.Initialize(requestContext)
    End Sub

    Function Index() As ActionResult
        ViewModel.EMP = EmpService.GetRecords(Me.Session("UserName").ToString,
                                              Me.Session("Password").ToString)
        Return View()
    End Function
End Class
Public Interface IEmpService
    Function GetRecords(ByVal userName As String, ByVal password As String) As DataSet
End Interface

Public Class EmpService
    Implements IEmpService

    Private block As Object
    Public Function GetRecords(ByVal userName As String,
                               ByVal password As String) As DataSet Implements IEmpService.GetRecords
        Dim ds As New DataSet

        Using _cn As New Oracle.DataAccess.Client.OracleConnection
            Try
                _cn.ConnectionString = String.Format(System.Configuration.ConfigurationManager.AppSettings("ConnectionString"),
                                                     userName,
                                                     password)
                _cn.Open()
                Using _cmd As New Oracle.DataAccess.Client.OracleCommand
                    _cmd.Connection = _cn
                    _cmd.CommandText = "SELECT * FROM SCOTT.EMP ORDER BY EMPNO"
                    Using _da As New Oracle.DataAccess.Client.OracleDataAdapter
                        _da.SelectCommand = _cmd
                        _da.Fill(ds, "EMP")
                    End Using
                End Using
            Finally
                _cn.Close()
            End Try
        End Using
        Return ds
    End Function
End Class
ASP.NET MVC 3 Preview1 + Oracle Providers for ASP.NET

23

こんなシステム構成が流行るかも

25

COPYRIGHT (C) 2008 初音玲 All rights reserved. / Running .NET Framework 4.0.30319.42000