c# - 休息时不会停止
问题描述
我正在使用while并在其中执行检查,我在else中放置了一个断点,看起来一切正常,代码执行验证并进入BREAK,但是循环并没有停止......
Cliente cliente = null;
do {
cliente = DataBase.Clientes.FirstOrDefault(x => x.Status == 0);
if (cliente.NossoNumero == string.Empty || cliente.Email == string.Empty) {
cliente.UpdateStatus(Status.Error);
}
else {
break;
}
}
while (DataBase.Clientes.FirstOrDefault(x => x.Status == 0) != null);
return cliente;
解决方案
如果您有多个客户端?为什么不返回 IEnumrable 列表然后更新每个客户端?
循环也不会停止,因为它说:
while (DataBase.Clientes.FirstOrDefault(x => x.Status == 0) != null);
等于
while (I have at least one client with status == 0)
推荐阅读
- security - 如何知道支持 sg_sanitize?
- c# - 统一的 Pubnub 空引用异常
- html - 如何在不移动 flexbox 容器中左侧的 div 的情况下移动右侧的 div?
- javascript - 如何在本地搜索巨大的 JSON 文件?
- python - 在 run_in_executor 中运行图像操作。适应多处理
- java - 如何在 Spring Boot 中使 ThreadPoolTaskExecutor 访问请求范围 bean
- r - R中不同维度数组的总和
- r - 如何在 csv 文件上运行多个函数,然后将结果写入 r 中的新 csv 文件?
- c++ - 虚幻宏蓝图到 C++
- numpy - NUMPY:是否有更易读的方式来索引 numpy 数组?