public override List<UploadedFile> GetFiles(Guid? id, Guid? parentId, string fileName, DateTime? initialDateCreated, DateTime? finalDateCreated, DateTime? initialLastUpdated, DateTime? finalLastUpdated, string contentType, bool includeData, int pageSize, int pageIndex, out int totalCount) { totalCount = 0; List<UploadedFile> results = new List<UploadedFile>(); #if GETFILES_W_SPROC int? _totalCount = null; UploadStorageDataContext db = new UploadStorageDataContext(ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString); var query = db.GetFiles(this.ApplicationName, id, contentType, initialDateCreated, finalDateCreated, fileName, initialLastUpdated, finalLastUpdated, parentId, pageIndex * pageSize, (pageIndex * pageSize) + pageSize, ref _totalCount); foreach (GetFilesResult item in query) results.Add(SelectFile(item.ID, includeData)); #else UploadStorageDataContext db = new UploadStorageDataContext(ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString); Table<PersistableUploadedFile> files = db.GetTable<PersistableUploadedFile>(); var query = from file in files where file.ApplicationName == this.ApplicationName where file.ID == (id.HasValue && id.Value != Guid.Empty ? id.Value : file.ID) where file.ParentID == (parentId.HasValue && parentId.Value != Guid.Empty ? parentId.Value : file.ParentID) where file.FileName == (!string.IsNullOrEmpty(fileName) ? fileName : file.FileName) where file.DateCreated >= (initialDateCreated.HasValue && initialDateCreated != DateTime.MinValue ? initialDateCreated.Value : file.DateCreated) where file.DateCreated <= (finalDateCreated.HasValue && finalDateCreated != DateTime.MinValue ? finalDateCreated.Value : file.DateCreated) where file.LastUpdated >= (initialLastUpdated.HasValue && initialLastUpdated != DateTime.MinValue ? initialLastUpdated.Value : file.LastUpdated) where file.LastUpdated <= (initialLastUpdated.HasValue && initialLastUpdated != DateTime.MinValue ? initialLastUpdated.Value : file.LastUpdated) where file.ContentType == (!string.IsNullOrEmpty(contentType) ? contentType : file.ContentType) orderby file.FileName ascending select file; foreach (PersistableUploadedFile item in query.Skip(pageSize * pageIndex).Take(pageSize)) results.Add(new UploadedFile(item)); totalCount = query.Count(); #endif return results; }