public List <UploadingPointData> GetArrayForUpload() { var user = Membership.GetUser(); Guid myUID = user == null ? new Guid() : (Guid)user.ProviderUserKey; var db = new DB(); IQueryable <MapObject> objList = db.MapObjects.AsQueryable(); if (SearchWord.IsFilled()) { objList = objList.Where( x => SqlMethods.Like(x.Address ?? "", "%" + SearchWord.Replace(" ", "%") + "%") || SqlMethods.Like(x.Name ?? "", "%" + SearchWord.Replace(" ", "%") + "%") || SqlMethods.Like(x.Description ?? "", "%" + SearchWord.Replace(" ", "%") + "%")); } else { objList = objList.Where( x => x.MapCoords.Any( z => z.XPos >= CurrentMapView.LeftUpperCorner.Lat && z.XPos <= CurrentMapView.RightBottomCorner.Lat && z.YPos >= CurrentMapView.RightBottomCorner.Lng && z.YPos <= CurrentMapView.LeftUpperCorner.Lng)); } if (IsFavorite == 1 && user != null) { objList = objList.Where(x => x.CreatorID == myUID); } if (SmokingType.HasValue) { objList = objList.Where(x => x.ObjectType == SmokingType); } if (ObjectFilter.SelectedTypes.Any()) { var typeFiltered = (from type in ObjectFilter.SelectedTypes let qs = objList.Where(x => x.TypeID == type.TypeID) select type.ObjectType == 0 ? qs.Where(x => x.MapCoords.All(z => z.IsMarker)) : qs.Where(x => x.MapCoords.Any(z => !z.IsMarker))) .Aggregate <IQueryable <MapObject>, IQueryable <MapObject> >(null, (current, qs) => current == null ? qs : current.Concat(qs)); objList = typeFiltered; } if (LoadedPoints.Any()) { objList = objList.Where(x => !LoadedPoints.Take(500).Contains(x.ID)); } return(objList.Take(100).ToList().Select(x => x.ToUploadData()).ToList()); }