5.0.19 #557
Replies: 1 comment 1 reply
-
Hey folks, To follow on with the changelog, let's look at what's really changed. You can count items without returning items.We had a feature request come in noting that they couldn't easily do a count without returning items. So there is now a "CountItemsAsync" method. You can use it like this: // Count the items in a table.
long items = await table.CountItemsAsync();
// Count the items in a search
long items = await table.Where(m => m.Title.StartsWith("The")).LongCountAsync(); You can convert to a variety of collection typesYou no longer need System.Linq.Async to convert to collection types. var items = await table.ToArrayAsync();
var items = await table.ToDictionaryAsync(t => t.Id);
var items = await table.ToHashSetAsync();
var items = await table.ToListAsync();
// You can even do an enumerable - just don't as it is a locking and blocking call.
var enumerable = table.ToEnumerable();
foreach (var item in enumerable)
{
// Do something with item
} Of course, all these methods can also be chained onto the query as well. There is a new thread-safe ObservableCollection.New type var collection = new ConcurrentObservableCollection<ItemDto>();
collection.ReplaceAll(listOfItems);
bool collectionModified = collection.AddRange(listOfItems);
// And single items with a predicate
bool collectionModified = collection.AddIfMissing(t => t.Id == item.Id, item);
bool collectionModified = collection.DeleteIf(t => t.Id == myId);
bool collectionModified = collection.ReplaceIf(t => t.Id == item.Id, item); You can populate an existing ConcurrentObservableCollection from a querySomething like: // Items is an observable collection as a bindable property in your view model
// This does ReplaceAll with the results of the table query.
await table.ToObservableCollectionAsync(Items);
// Or, if you want to generate a collection and populate it at the same time.
Items = await table.ToObservableCollectionAsync(); Selections that don't have an Id now workBefore, this bit of code didn't work: var items = await table.Select(t => new { t.Title }).ToListAsync(); You can an exception saying that Id was required (in much more obtuse language). That was because of the code I introduced last year when we deferred the creation of table collections until they were needed for lazy offline stores. That got fixed, so the above bit of code now works. |
Beta Was this translation helpful? Give feedback.
-
What's Changed
Full Changelog: 5.0.18...5.0.19
This discussion was created from the release 5.0.19.
Beta Was this translation helpful? Give feedback.
All reactions