public static Create ( string connectionString ) : |
||
connectionString | string | |
return |
public Task FindByName(string taskName) { using (var context = TasksContextFactory.Create(_connectionString)) { return(context.Tasks.FirstOrDefault(t => t.TaskName == taskName)); } }
public Task FindById(int taskId) { using (var context = TasksContextFactory.Create(_connectionString)) { return(context.Tasks.FirstOrDefault(t => t.Id == taskId)); } }
public IEnumerable <Task> FindAll() { using (var context = TasksContextFactory.Create(_connectionString)) { return(context.Tasks.ToList()); } }
public void Clear() { using (var context = TasksContextFactory.Create(_connectionString)) { context.Tasks.RemoveRange(context.Tasks); context.SaveChanges(); } }
public void Update(Task task) { using (var context = TasksContextFactory.Create(_connectionString)) { context.Update(task); context.SaveChanges(); } }
public Task Add(Task newTask) { using (var context = TasksContextFactory.Create(_connectionString)) { var task = context.Add(newTask); context.SaveChanges(); return(task.Entity); } }