Skip to content

Instantly share code, notes, and snippets.

@DominicFinn
Created November 22, 2012 11:11
Show Gist options
  • Save DominicFinn/4130607 to your computer and use it in GitHub Desktop.
Save DominicFinn/4130607 to your computer and use it in GitHub Desktop.
Generic Interface Problem
using System;
using System.Collections.Generic;
using TeaLeague.Core.Domain;
namespace TeaLeague.Core.Repository
{
//What's the best way to approach this, seen as StructureMap seems to have problems with open generics....
//This?
public interface IRepository
{
IEnumerable<T> List<T>() where T : IEntity;
T Get<T>(Guid id) where T : IEntity;
void CreateOrUpdate<T>(T user) where T : IEntity;
void Delete<T>(Guid id) where T : IEntity;
}
//Or this?
public interface IRepository<T>
{
IEnumerable<T> List();
T Get(Guid id);
void CreateOrUpdate(T entity);
void Delete(Guid id);
}
}
//Might have to do something like this....http://lostechies.com/jimmybogard/2009/12/18/advanced-structuremap-connecting-implementations-to-open-generic-types/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment