简体   繁体   English

LINQ to Entities(等待操作超时)

[英]LINQ to Entities (The wait operation timed out)

I would like to find a help here with one query.我想在这里找到一个查询的帮助。 I'm using Entity Framework and SQL DB in my ASP.NET MVC project.我在我的 ASP.NET MVC 项目中使用 Entity Framework 和 SQL DB。 There are records from molding machine.成型机有记录。 Every record has name like "156812 NameOfParameter" where the number is molding machine production number and name is a name of parameter, value and date .每条记录的名称如“156812 NameOfParameter”,其中数字是成型机生产编号,名称是参数名称、日期 A group of records with the same date is created every cycle of molding machine.成型机每一个循环都会产生一组日期相同的记录。 But there haven't to be all the parameters in the group of records.但不必是记录组中的所有参数。 This mean that value of missing parameter is same like value of first record with older date and name like "%NameOfParameter"这意味着缺少参数的值与具有较早日期和名称(如“%NameOfParameter”)的第一条记录的值相同

My goal is to crate list of Molding machine cycles.我的目标是创建成型机循环列表。 It means list of parameters with the same date and time (without milisecunds) and fill up all missing values.这意味着具有相同日期和时间(没有毫秒)的参数列表并填充所有缺失值。

Dataset from the database for specific molding machine and date from -> to来自特定成型机数据库的数据集和日期从 -> 到

var lisData = GetSet().Where(t => t.Name.Contains(cisloLisu));
            if (request.DateFrom.HasValue && request.DateTo.HasValue)
            lisData= lisData.Where(t => t.SampleDateTime >= request.DateFrom.Value && t.SampleDateTime <= request.DateTo.Value);

1) Grouping by date and time (without milisecunde) 1)按日期和时间分组(没有milisecunde)

            var set =
            from tag in lisData
            group tag by DbFunctions.CreateDateTime(
                tag.SampleDateTime.Year,
                tag.SampleDateTime.Month,
                tag.SampleDateTime.Day,
                tag.SampleDateTime.Hour,
                tag.SampleDateTime.Minute,
                tag.SampleDateTime.Second)
            into zdvih
            select zdvih;

Now i have IQueryble<IGrouping<DateTime?, HistDataView>> object.现在我有IQueryble<IGrouping<DateTime?, HistDataView>>对象。

2) From this object i need to do List of molding cycles 2)从这个对象我需要做成型周期列表

      var set2 =
            from zdvih in set
            let wz = 
                zdvih.FirstOrDefault(t => t.Name.Contains("Cislo nastroje")) ??
                lisData.FirstOrDefault(t => t.SampleDateTime < zdvih.Key && t.Name.Contains("Cislo nastroje"))
            let snr =
                zdvih.FirstOrDefault(t => t.Name.Contains("Cislo dilu")) ??
                lisData.FirstOrDefault(t => t.SampleDateTime < zdvih.Key && t.Name.Contains("Cislo dilu"))               
            select new ZdvihView()
            {
                Datum = zdvih.Key,
                CisloNastroje = wz.Value,
                CisloDilu = snr.Value,
            };

Problem is that i dont know why it take so much time.问题是我不知道为什么要花这么多时间。 Even if i look only for last hour.即使我只看最后一个小时。 I almost always get error "The wait operation timed out"我几乎总是收到错误消息“等待操作超时”

Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

Thanks for every help感谢您的帮助

Use default SQL Server profiler to watch the translated and executed TSQL queries.使用默认的 SQL Server 探查器来观察翻译和执行的 TSQL 查询。 It's possible the translated TSQL query take too much time to execute.翻译后的 TSQL 查询可能会花费太多时间来执行。 if not use linq profiler like Linq Insight to analyze your query and find the bottleneck.如果不使用像 Linq Insight 这样的 linq 探查器来分析您的查询并找到瓶颈。

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

相关问题 查找等待操作超时的原因 - Find Reason for The wait operation timed out 等待操作超时 - memory 问题 - The Wait Operation Timed Out - memory issues 等待操作超时。 ASP - The wait operation timed out. ASP 等待操作超时。 .aspx - The wait operation timed out. .aspx The wait operation timed out Win32Exception (0x80004005): The wait operation timed out azure - The wait operation timed out Win32Exception (0x80004005): The wait operation timed out azure 无法连接到SQL Server会话数据库-等待操作超时 - Unable to connect to SQL Server session database - The wait operation timed out ASP .NET应用中的sql命令“等待操作超时” - “wait operation timed out” for sql command in ASP .NET app 实体框架-排序字符串导致“等待操作超时” - Entity Framework - Sorting Strings is causing “The wait operation timed out” SQL Server Express (localdb) 等待操作超时——查询随机超时? - SQL Server Express (localdb) The wait operation timed out - query timing out at random? 目前,我的所有SQL请求显示“System.ComponentModel.Win32Exception:等待操作超时” - Currently, All my SQL Request showing “System.ComponentModel.Win32Exception: The wait operation timed out”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM