简体   繁体   English

相同的“哪里”每次返回不同的结果

[英]Same “Where” each time returns different result

I have a .NET service (using Entity Framework 6.0.0-rc-1) 我有一个.NET服务(使用Entity Framework 6.0.0-rc-1)

public class MyController : ApiController
{
    protected DbConnection _connection = new DbConnection();

    public HttpResponseMessage MyProcedure1()
    {
        ...
        var dayPlans = _connection.DayPlans
                          .Where(dp => dp.period >= start && dp.period < end);
        if (dayPlans.Count() > 0)
        {
            //success
        }
        else
        {
            //fail
        }
        ...
    }

    public HttpResponseMessage MyProcedure2()
    {
        ...
        var dayPlans = _connection.DayPlans
                          .Where(dp => dp.period >= start && dp.period < end);
        if (dayPlans.Count() > 0)
        {
            //success
        }
        else
        {
            //fail
        }
        ...
    }
}

These procedures being used simultaneously by client side. 客户端同时使用这些过程。 The thing is from time to time dayPlans.Count() equals zero while it should not. 事情是不时的dayPlans.Count()等于零,但它不应该为零。 I've double checked filtration params and database content, there are few records that has to be selected from db, but they are not. 我已经仔细检查了过滤参数和数据库内容,很少需要从db中选择记录,但事实并非如此。

Another important moment is when LINQ request in one method fails, it always fails in another. 另一个重要的时刻是,当一种方法中的LINQ请求失败时,另一方法中的LINQ请求总是失败。 But when these procedures are called one after another they might fail in all possible variants - first request failed, second succeeded; 但是,当这些过程一个接一个地调用时,它们可能会在所有可能的变体中失败-第一个请求失败,第二个成功; first failed second failed; 第一次失败,第二次失败; etc. 等等

What might be the problem? 可能是什么问题?

那是我的错误,日期边界计算不正确

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM