我正在使用Phonegap示例应用程序列出所有名称的联系人,但我无法这样做.
以下是我的onSuccess()
功能.我在这个函数的第二行中找到了7个联系人作为消息.我在获得这个名字的试验中展示了一些结果.
function onSuccess(contacts) {
navigator.notification.alert('Found ' + contacts.length + ' contacts.');
var con = document.getElementById('con');
for (var i = 0; i < contacts.length; i++) {
navigator.notification.alert(contacts[i].name);
}
};
Run Code Online (Sandbox Code Playgroud)
试验:
<br/>
1). navigator.notification.alert(contacts[i])<br/>
Result ->
{"id":"0","displayName":"Andrew Hill","nickname":"Andrew Hill",
"phoneNumbers":["(206)5550001"],"emails":["Andy@fai=urthcoffee.com"],
"addresses":["Microsoft.Phone.UserData.ContactAddress"],
"urls":["www.fourthcoffee..com"]}
and like in the same foramt for other 6 contacts.
2). navigator.notification.alert(contacts[i].name)<br/>
Result ->
message
like same for all.
3). navigator.notification.alert(contacts[i].name[i].value)<br/>
Result ->
shows nothing.
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得名称字段?
我试图在跳过 x 组的同时获取 n 组的所有行,因此我不必一次执行所有记录。通过这种方式,我可以实现分页以更快地加载数据。
下面的代码工作正常(没有跳过),我从前 2 个组中获取所有记录(按相同的 Id 分组)。
IOrderedQueryable<Patient> query = query.OrderBy(r => r.Id);
IQueryable<Patient> groupedQuery = query.GroupBy(x => x.Id).Take(2).SelectMany(g => g);
Run Code Online (Sandbox Code Playgroud)
但是要实现分页,当我尝试按以下方式添加“跳过”并调用groupedQuery.ToList();
.
IQueryable<Patient> groupedQuery = query.GroupBy(x => x.Id).Skip(2).Take(4).SelectMany(g => g);
Run Code Online (Sandbox Code Playgroud)
它抛出异常:
方法“跳过”仅支持 LINQ to Entities 中的排序输入。方法 'OrderBy' 必须在方法 'Skip' 之前调用。
有人可以建议正确的做法。
我有两个约会,想要查找包含两个日期的天数,我尝试过这样的事情:
select datediff("d", '10/11/2012', '10/12/2012')
Run Code Online (Sandbox Code Playgroud)
它显示1,但我希望结果为2,因为我们有2天11和12.