Basic Repository for using Universal Apps with Azure Mobile ServicesIf we are working with Mobile Services, it will be better to have a single entry point for our client applications to the service. Lets say if we are working with the default template (TodoItems). We will be having our default controller (TodoItemController) as:
Now lets go ahead and add a Folder named Repository to our Shared Project and add a BaseRepositoty class as:
We will be holding all of the CRUD operatiıons on our base. If we like, we can pass our expression tree to filter the lists. So lets add a repository for TodoItems as an example to follow.
Go ahead and add a new class called TodoRepository.cs as followed:
As you can see, basic Update or get methods can be executed from our base direcyly. On the other hand, on the RefreshTodoItems method, we will be passed the parameters and Expression tree will be formed for filtering. Another approach will be to pass parameter direcly to the server and filter the list accordingly. This approach can be used like:
And our solution will look like
If you have any questions please go ahead and ask.
comments powered by Disqus