This file contains hidden or 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
public abstract class Entity | |
{ | |
public virtual long Id { get; protected set; } | |
protected virtual object Actual => this; | |
public override bool Equals(object obj) | |
{ | |
var other = obj as Entity; | |
if (other is null) |
This file contains hidden or 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
public class Student : Entity | |
{ | |
public string FirstName { get; private set; } | |
public string LastName { get; private set; } | |
public int FavoriteCourseId { get; private set; } // Foreign key | |
} | |
public class Course : Entity | |
{ | |
public string Title { get; private set; } |
This file contains hidden or 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
public class PlanningTool | |
{ | |
internal int Id { get; private set; } | |
// Rest of class | |
public ICollection<PlanningToolTab> Tabs { get; private set; } | |
} | |
public class PlanningToolTab | |
{ |
This file contains hidden or 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
public class SomeService | |
{ | |
public void FirePeriodicJob() | |
{ | |
/* Runs asynchronously */ | |
} | |
} |
This file contains hidden or 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
public class StatisticsCalculator | |
{ | |
public async Task<(double weightDelivered, double totalCost)> Calculate(int customerId) | |
{ | |
List<DeliveryRecord> records = await GetDeliveries(customerId); | |
double weightDelivered = records.Sum(x => x.Weight); | |
double totalCost = records.Sum(x => x.Cost); | |
return (weightDelivered, totalCost); |
This file contains hidden or 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
public class OrderRepository | |
{ | |
public void Save(Order order) | |
{ | |
/* ... */ | |
} | |
public Order GetById(long id) | |
{ | |
/* ... */ |
This file contains hidden or 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
public class Customer | |
{ | |
public string Name { get; set; } | |
public string Email { get; set; } | |
} | |
Customer customer = GetCustomer(); | |
customer.Name = customer.Email; // Compiles perfectly |
This file contains hidden or 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
public class AllowanceAmount : ValueObject | |
{ | |
public const int MaxLength = 50; | |
public string Value { get; } | |
private AllowanceAmount(string value) | |
{ | |
Value = value; | |
} |
This file contains hidden or 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
public static class Calculator | |
{ | |
public static int Add(int value1, int value2) | |
{ | |
return value1 + value2; | |
} | |
} |
This file contains hidden or 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
Customer customer = await session.GetAsync<Customer>(1); |