Я делаю Linq to SQL с шаблоном репозитория, и EF с шаблоном репозитория также возможен.
public class BaseRepository : IDisposable
{
protected MyDataContext dc = null;
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
protected BaseRepository()
{
dc = new MyDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["My_ConnectionString"].ConnectionString, mappingSource);
}
}
I have an interface to my Object Repository :
interface IObjectRepository
{
...
}
and the object Repository:
public class ObjectRepository : BaseRepository, IObjectRepository
{
private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public ObjectRepository()
{
IList<Foo> GetFoos = GetFoos()
{
...
}
}
}