I currently have 4 static classes to access the data layer : one for each type of operations (select, insert, update, delete).
public static class DataAccess_SELECT
{
private static MyDBContext db = new MyDBContext();
public static List<T_News> GetAllNews()
{
return db.T_News.AsNoTracking().ToList();
}
public static List<T_News> GetAllNewsActif()
{
return db.T_News.AsNoTracking().Where(x => !x.DateDesactivation.HasValue || (DateTime.Now > x.DateActivation && DateTime.Now < x.DateDesactivation)).ToList();
}
public static List<T_Sondage> GetAllSondages()
{
return db.T_Sondage.AsNoTracking().ToList();
}
// (...)
}
I've read that it should be avoided to use static classes in that situation, how should I organize this otherwise ?
Thanks for your advice.