0

I am using azure mobile apps .net back-end for my windows 10 application and I would like to retrieve the column average from a table in my database. How can I do that? I have searched the internet and can't find anything useful.

My Table just has two columns; id (string) and Rating(int).

  • @Haksu I can't use that with IMobileServiceTable – Mishael Ogochukwu Nov 15 '16 at 12:37
  • Can you check this one. http://stackoverflow.com/questions/25474663/outputting-the-number-of-entities-in-an-azure-table . Another option if you can add additional TableController you could implement on the server side. @/mishael-ogochukwu – Miguel Nov 15 '16 at 13:12
  • @Haksu ok. How can use a tablecontroller to get the averages of a column. – Mishael Ogochukwu Nov 15 '16 at 13:25
  • You can find code samples here. https://github.com/Azure-Samples/app-service-mobile-dotnet-backend-quickstart/blob/master/todolist_completeService/Controllers/TodoItemController.cs If you look TodoItemController GetAllTodoItems method it returns IQueryable . Implement your tableController and extend the controller based on the your need. – Miguel Nov 15 '16 at 13:34

1 Answers1

0

There are a couple of ways.

1) Do a LINQ query against an offline version of the data. This will calculate the average on the client

2) Do a LINQ query against the online version of the data. This will calculate the average on the client, but pull all the data from the server, which may be less than desirable.

3) Implement a Custom API that returns the average. This will calculate the average on the server, and allow you to do some caching of the average for quicker access.

Adrian Hall
  • 7,990
  • 1
  • 18
  • 26
  • Options 3 is best for my use case. I'm just not sure how to implement it in my table controller. Resources on how to create custom API will be helpful. – Mishael Ogochukwu Nov 15 '16 at 19:32