Skip to content

Instantly share code, notes, and snippets.

@ro31337
Created August 22, 2014 11:58
Show Gist options
  • Save ro31337/569221616e74073f1e15 to your computer and use it in GitHub Desktop.
Save ro31337/569221616e74073f1e15 to your computer and use it in GitHub Desktop.
public class CompanyService
{
// ...
public Delete(long companyId)
{
var company = GetById(companyId);
company.DeletedAtUtc = DateTimeOffset.Now;
database.Companies.Remove(company); // it's like we usually delete
database.SaveChanges();
}
}
public class Company
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long CompanyId { get; set; }
public string Name { get; set; }
public bool IsDeleted { get; set; }
public DateTimeOffset? DeletedAtUtc { get; set; } // property added
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment