【发布时间】:2015-11-19 15:23:27
【问题描述】:
我正在尝试在 Azure 移动服务数据库中查询特定记录。我需要查询来查找其NotifyDate 列等于当前日期的记录。然后从找到的记录中,我想获取记录的Name 列中的字符串值,并将其存储在可以在数据库外部使用的字符串中。
这是我想出的,但它给了我一个错误:
无法将方法组“ToString”转换为非委托类型“字符串”。 您是否打算调用该方法?
在以下行:
string NotifyDate = FindNotifyDate().ToString;
您能想到更好的方法吗?
当前代码:
private IMobileServiceTable<TodoItem> todoTable =
MobileService.GetTable<TodoItem>();
private MobileServiceCollection<TodoItem, TodoItem> items;
private List<TodoItem> notifyItems;
protected void Application_Start()
{
WebApiConfig.Register();
string NotifyDate = FindNotifyDate().ToString;
}
public async Task<TodoItem> FindNotifyDate()
{
DateTime test = DateTime.Now;
test = test.AddMilliseconds(-test.Millisecond);
notifyItems = await todoTable.Where(todoItem => todoItem.NotifyDate == test)
.ToListAsync();
return notifyItems[0];
}
【问题讨论】:
标签: c# azure azure-mobile-services querying