public interface IRepository
public interface IEntity
{
object Id { get; }
}
public abstract class EphemeralRepository<t> : IRepository<t>
where T : IEntity
{
private IDictionary<object, T> storage;
public EphemeralRepository()
{
this.storage = new Dictionary<object, T>();
}
public T Get(object id)
{
return (this.storage.Keys.Contains(id) ? this.storage[id] : default(T));
}
public void Update(T entity)
{
this.storage[entity.Id] = entity;
}
public void Add(T entity)
{
this.storage.Add(entity.Id, entity);
}
}
The data layer can quickly become a time sink, especially since the amount of change in a new project is so high. There isn’t much value to spending time coding it initially. It is going to change, and you will have to update your repository, schemas, mapping files, etc.
I know I am not the first to offer this advice, but I think reinforcing it is important.