我有一个名为 Activity(移动服务)的表,我在阅读中添加了一个查询:
天青脚本:
function read(query, user, request)
{
var param = request.parameters.UserLocation;
if(param)
{
var sql = "Select TOP 10 [NewsItemUrl], count(1) as CounterNews FROM [MobileServiceExtra].[ACTIVITY] WHERE [UserLocation] = ? GROUP BY [NewsItemUrl] ORDER BY CounterNews Desc";
mssql.query(sql,param, {success: function(results) {request.respond(statusCodes.OK, results);}});
}
//request.execute();
}
客户端:
public class ACTIVITY
{
public int Id { get; set; }
[JsonProperty(PropertyName = "UserLocation")]
public string _UserLocation { get; set; }
[JsonProperty(PropertyName = "NewsItemUrl")]
public string _NewsItemUrl { get; set; }
[JsonProperty(PropertyName = "NewsItemTitle")]
public string _NewsItemTitle { get; set; }
[JsonProperty(PropertyName = "NewsItemPublisher")]
public string _NewsItemPublisher { get; set; }
}
如果我在 sql 中进行查询,我会得到 2 列 CounterNews 和 NewsItemUrl,其中 Last 是重复 url 的次数。但是,我不知道如何获取“CounterNews”列中的数据,我的意思是,当我想获取查询时,我会处理 Activity 表(类)并且显然正确地返回了我的数据,但只有 NewsItemUrl 列其他字段为空。
客户端:
private MobileServiceCollection<ACTIVITY, ACTIVITY> TopReadCollectionActivity;
private IMobileServiceTable<ACTIVITY> ACTIVITYTable = App.MobileService.GetTable<ACTIVITY>();
private async void LoadTop10()
{
var dict = new Dictionary<string, string>
{
{ "UserLocation", "United States" },
};
try
{
TopReadCollectionActivity = await ACTIVITYTable.WithParameters(dict).ToCollectionAsync();
}
catch (Exception ex)
{
string err = ex.Message;
}
}
如果我创建一个类(表)“Top10”,天蓝色会出错,因为该表不存在。并且不想创建一个新表。如何获取只有两个字段 CounterNews 和 NewsItemUrl 的查询?