MikeCodesDotNET / App-Service-Helpers

Add data storage and authentication to your app in a few lines of code.
MIT License
79 stars 28 forks source link

Add in the ability for BaseAzureViewModel<T> to customise data loaded #17

Closed glennstephens closed 8 years ago

glennstephens commented 8 years ago

It would be beneficial when the data is loaded to be able to restrict what is loaded. It is quite likely that someone would want to restrict as it may be part of a one-to-many, many-to-many relationship or just filtering based on some device identifier.

Doing something like changing

var _items = await table.GetItemsAsync();

to a virtual method such as

var _items = await GetItemsForTable();
...
protected virtual Task<IList<T>> GetItemsForTable()
{
    return table.GetItemsAsync();
}

would allow users to have the flexibility of customising what they bring down for the table in more complex situations.

pierceboggan commented 8 years ago

@glennstephens, thanks for the feedback!

For customization scenarios, you should subclass BaseTableDataStore<T> with your type, from which you can customize (as all methods are virtual). At registration time, instead of client.RegisterTable<TodoItem>, you will use client.RegisterTable<TodoItem, TodoItemDataStore>, which allows you to use custom data stores rather than our defaults. 👍

We should update the README to reflect this.

pierceboggan commented 8 years ago

Closing this out, if you have any issues / additional feedback, feel free to re-open the issue. 👍