Note that there are some explanatory texts on larger screens.

plurals
  1. POOne Table, Several Views, one C# Class
    primarykey
    data
    text
    <p>I have a single c# class defined as</p> <pre><code>class HighScore { public int Id { get; set; } [DataMember(Name = "PlayerName")] public string PlayerName { get; set; } [DataMember(Name = "PlayerCountry")] public int PlayerCountry { get; set; } [DataMember(Name = "PlayerTime")] public double PlayerTime { get; set; } [DataMember(Name = "PlayerBadge")] public int PlayerBadge { get; set; } } </code></pre> <p>And a table in my Azure mobile services SQL database that contains several records of this type. I have a number of views</p> <pre><code>select * from tellingthetime.HighScore where PlayerBadge=0 </code></pre> <p>where the PlayerBadge is a number from 0 to 4. I also have a number of read scripts added to my Mobile Service that query the view and return the appropriate rows.</p> <pre><code>function read(query, user, request) { mssql.query("select * from OneStarBadgeLeaderBoard", { success: function(results) { console.log(results); request.respond(statusCodes.OK, results); } }); } </code></pre> <p>The above script is called OneStarBadgeLeaderBoard, but my class is called HighScore. The code below I call to Get the underlying table. </p> <pre><code>private IMobileServiceTable&lt;HighScore&gt; HighScoreTable = App.MobileService.GetTable&lt;HighScore&gt;(); </code></pre> <p>Without creating a different class name, the defintions are all the same as the SQL returned data is the same, for each read script, how do I make this work so I can call any read script, which queries the appropriate view to retrieve the values I need?</p> <p>Hope that make sense.</p> <p>Many thanks,</p> <p>Jason.</p> <p>P.S. Of course, I could read the entire table and query it with LINQ on the client, but that will increase the amount of data to download.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload