/// <summary> /// Generic method to get a collection of Entities /// </summary> /// <param name="filter">Filter expression for the return Entities</param> /// <param name="orderBy">Represents the order of the return Entities</param> /// <param name="includeProperties">Include Properties for the navigation properties</param> /// <returns>A Enumerable of Entities</returns> public virtual IEnumerable <TEntity> Get(Expression <Func <TEntity, bool> > filter = null, Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > orderBy = null, string includeProperties = "") { IQueryable <TEntity> query = unitofwork.Set <TEntity>(); if (filter != null) { query = query.Where(filter); } if (!String.IsNullOrEmpty(includeProperties)) { foreach (var includeProperty in includeProperties.Split (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { query = query.Include(includeProperty); } } if (orderBy != null) { return(orderBy(query).ToList()); } else { return(query.ToList()); } }
/// <summary> /// Delete NewsletterTask from context /// </summary> /// <param name="task"></param> public void DeleteNewsletterTask(NewsletterTask task) { currentunitofwork.Set <NewsletterTask>().Remove(task); }