This post is part of series of post on Single Page Application using ASP.NET MVC 4. We will explore the upshot
What is Upshot.js?
Upshot is for data access and related functionalities like paging, sorting, change tracking. Upshot.js is designed to work with DataController and oData (only data reading).
Objects provided by Upshot
- EntitySource : a wrapper of array of Entities which are observable. provides method to bind/unbind events
- EntityView : inherits from EntitySource and provides change tracking on it
- DataSource : inherits from EntityView and add paging, sorting and filterting support on it.
- DataProvider : a wrapper over jQuery ajax to get and submit entity values
- EntitySet : inherits from EntitySource and provides change tracking on EntityType. This object does the heavy lifting of managing entities
TODO: Update more about these objects
Usage of Upshot in ASP.NET MVC4 SPA
On creating a Single Page Application controller, we got code generated for the View and ViewModel. In the ViewModel code we can some usage of Upshot.
The RemoteDataSource are created with dataSourceOptions. DataSource options contains property values for dataProvider parameters ( url and oprationName), entityType , bufferChanges, mapping
Fetching data using DataSource
In the above code getEntities() method is used to get all TodoItem entities, and getFirstEntity() to get first TodoItem entity.
Another way to load data is to call refresh.
Saving data using DataSource
Deleting data using DataSource