'ibatis.net'에 해당되는 글 3건

  1. 2012.10.22 [iBatis.Net] 3) 샘플
  2. 2012.10.22 [iBatis.Net] 2) XML 파일 (쿼리) 작성
  3. 2012.10.22 [iBatis.net] 1) 준비
2012. 10. 22. 17:39

첨부파일 참조..



MyBitis.zip


Posted by CoolDragon
2012. 10. 22. 17:31

<?xml version="1.0" encoding="utf-8" ?>

<sqlMap namespace="UserInfo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ibatis.apache.org/mapping">

  <alias>

    <typeAlias alias="MyUser"  type="MainApp.MyUser" />

  </alias>


  <statements>

    <!-- 동적 테이블 생성 -->

    <statement id='Create_Login_Log'>

      IF NOT EXISTS (SELECT 'X' FROM sysobjects where xtype = 'U' and name = 'Login_Log$yyyymm$')

      BEGIN

      create table Login_Log$yyyymm$

      (

      id int identity(1,1),

      name nvarchar(100)

      );

      END;


      IF NOT EXISTS (SELECT 'X' FROM sysobjects where xtype = 'U' and name = 'Login_Log2_$yyyymm$')

      BEGIN

      create table Login_Log2_$yyyymm$

      (

      id int,

      name nvarchar(100)

      );

      END;

    </statement>


    <!-- 동적 생성 테이블 데이터 Insert  -->

    <insert id="Insert_Login_Log" resultClass="int" >

      INSERT INTO Login_Log$yyyymm$ (name)

      VALUES (#name#);

      <selectKey resultClass="int" property="id" type="post" >

        SELECT @@IDENTITY AS VALUE;

      </selectKey>

    </insert>


    <!-- 동적 생성 테이블 데이터 Insert  -->

    <insert id="Insert_Login_Log2" resultClass="int" >

      INSERT INTO Login_Log2_$yyyymm$ (id, name)

      VALUES (#id#, #name#);

    </insert>


    <!-- 동적 테이블 데이터 조회 -->

    <select id="Select_Login_Log">

      SELECT *

      FROM Login_Log$yyyymm$ a inner join Login_Log2_$yyyymm$ b on a.id = b.id

      WHERE b.id = #id#;

    </select>

  </statements>

</sqlMap>

Posted by CoolDragon
2012. 10. 22. 17:25

1) iBatis.Net 프레임워크 다운로드

    http://blog.mybatis.org/


2) .NET 프로젝트 생성


3) iBatis.Net DLL 참조


4) config 파일 설정

 - provider 파일

 - sqlmap 파일

 - query 파일

Posted by CoolDragon