첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ SQL Server 테이블

CREATE TABLE dbo.Student
(
    ID         INT          NOT NULL
   ,Name       NVARCHAR(50) NOT NULL
   ,CreateTime DATETIME     NOT NULL
    CONSTRAINT PKStudent PRIMARY KEY CLUSTERED
    (
	    ID ASC
    )
    WITH
    (
        PAD_INDEX              = OFF
       ,STATISTICS_NORECOMPUTE = OFF
       ,IGNORE_DUP_KEY         = OFF
       ,ALLOW_ROW_LOCKS        = ON
       ,ALLOW_PAGE_LOCKS       = ON
    ) ON [PRIMARY]
) ON [PRIMARY]
GO

 

728x90

 

▶ C#

using System;
using System.Data.SqlClient;

using Dapper;

...

/// <summary>
/// 학생
/// </summary>
public class Student
{
    /// <summary>
    /// ID
    /// </summary>
    public int ID { get; set; }

    /// <summary>
    /// 성명
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 생성 일시
    /// </summary>
    public DateTime CreateTime { get; set; }
}

...

string connectionString = "Data Source=127.0.0.1;Initial Catalog=TestDB;UID=sa;PWD=1234;Timeout=30";

using(SqlConnection connection = new SqlConnection(connectionString))
{
    connection.Open();

    Student student = new Student();

    student.ID = 1;

    connection.Execute("DELETE FROM dbo.Student WHERE ID = @ID", student);
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요