728x90 반응형 전체 글303 ASP.NET Core] HTTP error status code 404 처리 endpoint가 없는 /files 경로를 호출한 경우 404 error status code를 처리할 수 있는 방법을 살펴보자. 1. UseStatusCodePages var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/Error"); } app.UseStatusCodePages(); 엔드포인트를 찾을 수 없다는 브라우저 종속 오류 메시지가 반환된다. 2.UseStatusCodePages(response content type, text를 지정하는 방법) using static System.Net.Mime.Me.. 2023. 5. 12. ASP.NET Core] Entity Framework Core - SQL Queries EF Core는 RDB에서 SQL 쿼리를 사용하도록 허용한다. LINQ를 사용할 수 없거나 비효율적인 SQL이 생성되는 경우 또는 keyless entity type이나 regular entity types을 반환하는 경우 사용할 수 있다. Basic SQL queries 1. FromSql public static System.Linq.IQueryable FromSql (this Microsoft.EntityFrameworkCore.DbSet source, FormattableString sql) where TEntity : class; interpolated string 으로 SQL query에 기반한 LINQ query를 만든다. EF Core 7.0에서 도입되었으며, 이전 버전 사용 시 FormS.. 2023. 5. 9. ASP.NET Core] Asynchronous Generic Repository synchronous repository를 asnychronous repository로 변경해보자. 기존 IRepositoryBase, Repository 소스는 다음과 같다. using System.Linq.Expressions; namespace TEST.Data { public interface IRepoBase { IQueryable FindAll(); IQueryable FindByCondition(Expression expression); T GetById(int id); void Create(T entity); void Update(T entity); void Delete(T entity); } } using Microsoft.EntityFrameworkCore; using System.Li.. 2023. 4. 26. ASP.NET Core] Asynchronous Programming - Async, Await 출처 : https://code-maze.com/asynchronous-programming-with-async-and-await-in-asp-net-core/ Asynchronous Programming과 장점 비동기 프로그래밍을 사용하면, 병목현상을 피하고, 앱의 반응성을 개선할 수 있다. thread pool의 고갈이나 앱 blocking 없이 시스템 흐름을 실행할 수 있수 있도록 하는 프로그래밍 기술이다. async, await keywords를 사용하므로 앱의 실행속도를 향상시킬 수 있다는 잘못된 개념이 있다. database로부터 데이터를 가져오는데 3초가 걸린는 synchronous code가 있다면, asynchronous code에서 그 시간이 빨라지지는 않는다. 하지만, 얼마나 많은 동.. 2023. 4. 26. C#] Asynchronous VS Multithreading 출처 : https://code-maze.com/csharp-async-vs-multithreading/ 병렬 프로그래밍의 두가지 주요 기술인 비동기와 멀티스레드에 대해서 알아보자. Asynchronous Programming 비동기 프로그래밍은 메인 프로그래밍의 흐름과 독립적으로 statements set이 실행되는 병렬프로그래밍 형태이다. 프로그램에 blocking operation을 갖고 있을 때, 결과 대기 없이 프로그래밍의 실행을 계속하고 싶을 때 사용한다. 동시에 tasks를 실행할 수 있도록 한다. C#에서는 async, await 키워드로 비동기 프로그래밍을 할 수 있다. Multithreading thread는 프로그램 내에서 하나의 지속되는 흐름이다. Multithreading은 pro.. 2023. 4. 25. ASP.NET Core - MVC] Repository Pattern Repository Pattern이란? 데이터, 도메인, Data Access Layers(Entity Framework Core 또는 Dapper)사이의 중재 역할을 한다. 데이터를 저장 또는 가져오는데 필요한 로직을 갖는 클래스이다. Repository Pattern의 장점 중복 쿼리 감소 Repository에 data access code를 작성하고, 여러개의 Controllers/Libraries에서 호출해서 사용할 수 있다. Data Access Layer로부터 Application의 De-couples ASP.NET Core에는 다양한 ORM이 유효하다. 현재 가장 유명한 것은 Entity Framework Core이다. 하지만 시간이 지나면서 새로운 기술이 발전함에 따라 새로운 ORM을 사용.. 2023. 4. 25. 이전 1 ··· 15 16 17 18 19 20 21 ··· 51 다음 728x90 반응형