컴퓨터 프로그래밍에서 동사 project의 뜻
Projection refers to the operation of transforming an object into a new form that often consists only of those properties subsequently used.
Projection operations (C#)
영한 사전들에서 동사 project의 뜻을 찾아 보면 대체로 투사한다는 뜻이다. 윅셔너리나 다른 영영 사전들에도 비슷하다. 하지만 컴퓨터 프로그래밍에서 project는 transform이라는 뜻이다.
Projects each element of a sequence into a new form
Enumerable.Select Method
IEnumerable<DateOnly> CreateDates(SqliteConnection connection)
{
string sql = "select Date from Days where Symbol = 'IBM' order by Date";
return connection.Query<DateTime>(sql).Select(DateOnly.FromDateTime);
}
위 코드에서 select는 DateTime인 엘리먼트들을 DateOnly.FromDateTime의 결과인 DateOnly로 바꾼다. FromDateTime()이라 하지 않은 이유는 select가 func를 아규먼트로 받기 때문이다.
Select<TSource,TResult>(IEnumerable<TSource>, Func<TSource,Int32,TResult>)
Select<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)
메떠드는 func의 아규먼트로 넘길 수 없고 메떠드 그룹은 가능하다.
메떠드를 오버로드하면 괄호 블록을 뺀 이름을 메떠드 그룹이라 한다. 오버로드하지 않은 메떠드라 해도 func 패러미터에 아규먼트로 넘길 때에는 메떠드 그룹의 형태로 넘겨야 한다. 위의 DateOnly.FromDateTime가 그런 경우다.