Skip to content

속성 값을 동반한 개정 모델 인스턴스 생성 #15

@gyuwon

Description

@gyuwon

모델의 특정 속성 혹은 속성들의 값을 변경한 개정 인스턴스를 생성하는 작업을 도와주는 확장 메서드 집합을 제공합니다. 아래 코드를 참고하세요.

public User
{
    public User(Guid id, string userName, string email, string bio)
    {
        Id = id;
        UserName = userName;
        Email = email;
        Bio = bio;
    }

    public Guid Id { get; }
    public string UserName { get; }
    public string Email { get; }
    public string Bio { get; }
}

var user = new User(
    Guid.NewGuid(),
    "Obiwan Kenobi",
    "[email protected]",
    "Jedi master");

User revision1 = user.ReviseWith(x => x.Email, "[email protected]");

User revision2 = revision1
    .Revise()
    .With(x => x.UserName, "Ben Kenobi")
    .With(x => x.Bio, "The Force will be with you, always.");

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions