我有这个代码:
IEnumerable<Users> allItems = await MobileService.GetTable<Users>().CreateQuery().ToEnumerableAsync();
foreach (var item in allItems) {
if (item.Email.Equals(emailEntry.Text)) {
emailIsValid = true;
}
}
它将检索我的 azure 表中的所有项目,然后检查在文本字段中输入的电子邮件是否有效(与 azure 表中的电子邮件匹配)。问题是在我看来,由于我的表中可能有数千个用户登录,我不知道这种电子邮件验证方法在性能方面是否可行,如果不可行,什么是更好的方法这个?
最佳答案
构建查询来完成服务器端的大部分繁重工作。应用过滤器以减少线路上的数据量。
类似这样的事情
var email = emailEntry.Text;
var query = await MobileService.GetTable<Users>()
.Where(item => item.Email == email)
.ToEnumerableAsync();
var emailIsValid = query.Any();
除非需要使用所有用户,否则不需要获取所有用户。
关于c# - Azure 查询可能存在性能问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48038082/