1. why use Database

  - 모든 데이터는 메모리에서 적재되어 이용됨

  - 웹서버 생명주기 모델에 따라 대부분의 경우 Response 후 제거 

  - TempData, Cache 등으로 생명주기를 늘릴 수 있으나, 웹서버 종료 시 삭제됨

 

2. 영속성(Persistence)

  - 메모리가 아닌 별도의 저장공간을 이용하여, 영구적인 저장을 가능하도록 함

  - 영속성이라는 의미는 데이터의 불변성이 아님

  - 즉, 서버를 껐다 켜도 데이터가 살아 있느냐를 생각해 보면 된다. 

 

(웹서버 IIS나 Tomcat 같은 것) 

데이터 베이스 서버 (Maria DB, oracle, MSSQL... ) RDBMS

 

영속성 개념 

3. 

MariaDb - License 문제에서 자유로움

            - MS-SQL Express 또는 Oracle XE 가 있으나 제약이 큼 

            - ANSI SQL 기준으로 쿼리를 만들 것이므로 다른 DB에도 쉽게 적용이 가능하다. 

 

-> 우리는 DB MSSQL로 진행 

 

4. ADO.NET 예제 

   - CRUD(Create, Read, Update, Delete) 예제 

 

5. Dapper 예제

  - ADO.NET 로 만든 CRUD 를 Dapper로 변경 

 

 

JAVA - DB 연결 

  1. JDBC

  2. JDBC mybatis ibatis

  3. JDBC Hibernate (DB에 있는 테이블이나 컬럼들이 하나의 오브젝트고, 프로퍼티가 되는 것. 그것을 자바 코드와 연결해서 매핑시켜 줌) 

 

 C#에서 DB 연결하는 방법

   1. ADO.NET (가장 기본적인 DB 연결 방식) 

using System;
using System.Data;
using System.Data.SqlClient;

class Program
{
    static void Main()
    {
        string connectionString =
            "Data Source=(local);Initial Catalog=Northwind;"
            + "Integrated Security=true";

        // Provide the query string with a parameter placeholder.
        string queryString =
            "SELECT ProductID, UnitPrice, ProductName from dbo.products "
                + "WHERE UnitPrice > @pricePoint "
                + "ORDER BY UnitPrice DESC;";

        // Specify the parameter value.
        int paramValue = 5;

        // Create and open the connection in a using block. This
        // ensures that all resources will be closed and disposed
        // when the code exits.
        using (SqlConnection connection =
            new SqlConnection(connectionString))
        {
            // Create the Command and Parameter objects.
            SqlCommand command = new SqlCommand(queryString, connection);
            command.Parameters.AddWithValue("@pricePoint", paramValue);

            // Open the connection in a try/catch block.
            // Create and execute the DataReader, writing the result
            // set to the console window.
            try
            {
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Console.WriteLine("\t{0}\t{1}\t{2}",
                        reader[0], reader[1], reader[2]);
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadLine();
        }
    }

  2. Enterprise Library

    - ADO.NET에서 불편했던 내용들을 보완한 것 

    - 개발자가 직접 쿼리를 작성해야 한다

  3. EntityFramework (엔티티 프레임워크) + Linq 쿼리식 

    - ORM 도구 

    - ADO.NET이나 Enterprise Library를 배우는 건 솔직히 의미 없음 

   

일반 SQL => SELECT * FROM user WHERE userNo = 1; 

 

Linq 쿼리식 => user.where(u=>u.userNo = 1) // C# 코드로 구성이 되어 있음 

 

 

 

 

'Develop > ASP.NET CORE' 카테고리의 다른 글

05-1 MSSQL - ASP.NET CORE 연동  (0) 2021.03.05
04 - Layout 구성  (0) 2021.03.04
03 - 데이터 전달  (0) 2021.03.03
02 - MVC 프로젝트 생성  (0) 2021.03.03
01 - ASP.NET CORE 시작하기  (0) 2021.03.03