protected override T GetSingleCore(System.Linq.Expressions.Expression <Func <T, bool> > filter, bool getDefaultFilter) { if (DefaultFilter != null) { filter = filter.And(DefaultFilter); } return(CurrentCloudTable.CreateQuery <T>().Where(filter).SingleOrDefault()); }
public override void Delete(System.Linq.Expressions.Expression <Func <T, bool> > filter) { var returnList = CurrentCloudTable.CreateQuery <T>().Where(filter).ToList(); if (returnList != null && returnList.Any()) { foreach (var entity in returnList) { CurrentBatchOperation.Delete(entity); } } }
protected override bool AnyCore(System.Linq.Expressions.Expression <Func <T, bool> > filter, bool getDefaultFilter) { if (getDefaultFilter && DefaultFilter != null) { filter = filter.And(DefaultFilter); } if (filter == null) { filter = query => true; } return(CurrentCloudTable.CreateQuery <T>().Any(filter)); }
protected override IQueryable <T> GetAllCore(System.Linq.Expressions.Expression <Func <T, bool> > filter, bool getDefaultFilter, bool getDefaultSorter, string sortColumn, SortDirection?sortDirection, bool allowPaging, int pageSize, int pageIndex, ref int totalCount) { if (getDefaultFilter && DefaultFilter != null) { filter = filter.And(DefaultFilter); } if (filter == null) { filter = query => true; } IQueryable <T> returnList = CurrentCloudTable.CreateQuery <T>().Where(filter).ToList().AsQueryable(); if (!String.IsNullOrEmpty(sortColumn)) { returnList = returnList.Sort(sortColumn, sortDirection); } else if (getDefaultSorter && DefaultSorter != null) { if (DefaultSortType == SortDirection.Ascending) { returnList = returnList.OrderBy(DefaultSorter); } else { returnList = returnList.OrderByDescending(DefaultSorter); } } if (allowPaging && pageSize > 0) { if (totalCount == 0) { totalCount = returnList.Count(); } int skipCount = pageSize * pageIndex; returnList = returnList.Skip(skipCount).Take(pageSize); } return(returnList); }
public override void Save() { if (NewItems.Any()) { foreach (T entity in NewItems) { CurrentBatchOperation.InsertOrReplace(entity); } NewItems = new List <T>(); } if (CurrentBatchOperation.Any()) { if (CurrentBatchOperation.Count > PageCount) { int pager = 0; int currentListCount = 0; do { var items = CurrentBatchOperation.Skip(pager * PageCount).Take(PageCount).ToList(); currentListCount = items.Count(); var pagedBatchOperation = new TableBatchOperation(); foreach (var item in items) { pagedBatchOperation.Add(item); } CurrentCloudTable.ExecuteBatch(pagedBatchOperation); pager++; }while (currentListCount == PageCount); } else { CurrentCloudTable.ExecuteBatch(CurrentBatchOperation); } CurrentBatchOperation.Clear(); } }