-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
74 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
USE [EFCoreDDD] | ||
GO | ||
BEGIN TRANSACTION | ||
GO | ||
EXECUTE sp_rename N'dbo.Student.Name', N'Tmp_FirstName', 'COLUMN' | ||
GO | ||
EXECUTE sp_rename N'dbo.Student.Tmp_FirstName', N'FirstName', 'COLUMN' | ||
GO | ||
ALTER TABLE dbo.Student ADD | ||
LastName nvarchar(50) NOT NULL CONSTRAINT DF_Student_LastName DEFAULT '' | ||
GO | ||
ALTER TABLE dbo.Student | ||
DROP CONSTRAINT DF_Student_LastName | ||
GO | ||
ALTER TABLE dbo.Student SET (LOCK_ESCALATION = TABLE) | ||
GO | ||
COMMIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Collections.Generic; | ||
using CSharpFunctionalExtensions; | ||
|
||
namespace App | ||
{ | ||
public class Name : ValueObject | ||
{ | ||
public string First { get; } | ||
public string Last { get; } | ||
|
||
protected Name() | ||
{ | ||
} | ||
|
||
private Name(string first, string last) | ||
: this() | ||
{ | ||
First = first; | ||
Last = last; | ||
} | ||
|
||
public static Result<Name> Create(string firstName, string lastName) | ||
{ | ||
if (string.IsNullOrWhiteSpace(firstName)) | ||
return Result.Failure<Name>("First name should not be empty"); | ||
if (string.IsNullOrWhiteSpace(lastName)) | ||
return Result.Failure<Name>("Last name should not be empty"); | ||
|
||
firstName = firstName.Trim(); | ||
lastName = lastName.Trim(); | ||
|
||
if (firstName.Length > 200) | ||
return Result.Failure<Name>("First name is too long"); | ||
if (lastName.Length > 200) | ||
return Result.Failure<Name>("Last name is too long"); | ||
|
||
return Result.Success(new Name(firstName, lastName)); | ||
} | ||
|
||
protected override IEnumerable<object> GetEqualityComponents() | ||
{ | ||
yield return First; | ||
yield return Last; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters