C#(asp.net | asp.net core)
-
[C#] IEnumerator | LINQ service 사용해서 문자열 출력C#(asp.net | asp.net core) 2021. 8. 11. 11:17
C#에서 문자열을 IEnumerator, LINQ로 접근할 수 있다 IEnumerator 사용법 우선 문자열을 하나 선언해보자 string strS = $"Hello, World!"; 문자열을 출력하는 코드이다 IEnumerator pointer = strS.GetEnumerator(); while (pointer.MoveNext()) { Write(pointer.Current); } 문자열인 집합 데이터셋의 Array를 반환한다 Array의 접근 방법은 pointer.MoveNext() 하면 다음 문자열로 넘어가고 pointer.Current하면 현재값에 접근할 수 있다 LINQ LINQ를 사용하면 더욱 간단하게 문자열 출력할 수 있다 strS.ToList().ForEach(kkk=>Write(kkk));
-
[C#] functional coding | callbackC#(asp.net | asp.net core) 2021. 8. 10. 17:20
int One() => 1; int Two() => 2; int Three() => 3; int Four() => 4; int Five() => 5; int Six() => 6; int Seven() => 7; int Eight() => 8; int Nine() => 9; int Ten() => 10; // javascript/dynamic program Func TenAddFunc = AddCalc(Ten()); Func TenSubFunc = SubCalc(Ten()); Func TenMulFunc = MulCalc(Ten()); Func TenDivFunc = DivCalc(Ten()); Func FiveAddFunc = AddCalc(Five()); Func FiveSubFunc = SubCalc..
-
MVC Pattern 자동 생성 프로젝트 - New Scaffolded ItemC#(asp.net | asp.net core) 2021. 8. 10. 14:34
MVC Application 생성 후 1. Model을 생성한다 using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace WebApplication1.Models { // Table=Entity (tuple의 집합) public class Saram { public int Id { get; set; } = default(int); public int Age { get; set; } = default(int); public string Name { get; set; } = default(string); public bool Gender { get; set; } = defau..
-
C# state operation | record 사용법C#(asp.net | asp.net core) 2021. 8. 9. 16:45
C#에서 record를 가지고 state operation에 대해 알아보겠다 우선 record를 생성해보자 public record Person(string FirstName, string LastName); Person 객체를 생성해보자 Person person = new Person("minsu", "kim"); 이 person 객체를 사용해서 person2를 생성해보자 Person person2 = person with {FirstName = "aaa"}; person과 person2는 같은 객체일까? 답은 true이다 person의 FirstName이라는 state를 변경하고 person 객체를 person2에 저장하였기 때문에 동일하다 person과 person2의 FirstName 을 보면 "..
-
[asp.net core] EntityFramwork Core Oracle 연동하기C#(asp.net | asp.net core) 2021. 7. 9. 15:58
Visual Studio 에서 EntityFramework Core와 Oracle 이 연동하는 방법을 알아보겠다 우선 EntityFramework Core와 Oracle EntityFramework Core를 설치한 상태이다 Model 생성 Models 폴더에 DB에 저장할 객체 정의하는 클래스를 저장한다 예를 들어 File에 대한 정보를 저장할 UploadFile 이라는 클래스를 생성해보자 using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; namespace VolvoWebDocMVC.Models { p..
-
[asp.net / asp.net core] HttpException (0x80004005) : 최대 요청 길이를 초과했습니다 파일 업로드 에러C#(asp.net | asp.net core) 2021. 7. 7. 14:37
asp.net 파일 업로드를 할 때 용량이 크면 나오는 에러이다 해결하는 방법은 web.config 에서 아래 코드를 추가해주면된다 우선 httpRuntime 코드를 Ctrl + F 로 찾아서 최대 용량을 100MB 로 바꿔준다 그리고 configuration 코드가 닫기 전 윗 줄에 코드를 추가한다 서버를 껐다가 다시 키면 이제 100MB 까지는 파일이 업로드가 될 것이다 asp.net core 일때를 알아보자 asp.net core 프로젝트를 생성하면 web.config 라는 파일이 안보인다 프로젝트 > Add > New Item > XML File 을 클릭한 후 web.config 파일을 생성한다 web.config 파일에 위 코드를 입력해준다 마지막으로 Startup.cs에 코드를 입력해부면 2G..