We are currently experiencing a problem with Entity Framework which generates a sp_executesql
statement. This statement is below. The statement runs fine in SQL Server however through the front end this just causes the application to hang.
Further to this other parameters with the same query run fine. The only way we have managed to get the system working again using the original parameter is to run sp_refreshview
which makes no sense as the underlying tables haven't changed and also the query runs fine in SQL Server.
Does anyone have any ideas what may be causing this?
exec sp_executesql N'SELECT TOP (1)
[Project1].[Id] AS [Id],
[Project1].[WorkCentreId] AS [WorkCentreId],
[Project1].[WorksOrderId] AS [WorksOrderId],
[Project1].[Operator] AS [Operator],
[Project1].[BookingDate] AS [BookingDate],
[Project1].[StartTime] AS [StartTime],
[Project1].[Duration] AS [Duration],
[Project1].[TotalProduced] AS [TotalProduced],
[Project1].[RejectQty] AS [RejectQty],
[Project1].[Item] AS [Item],
[Project1].[Mould] AS [Mould],
[Project1].[BatchCode] AS [BatchCode],
[Project1].[Complete] AS [Complete],
[Project1].[Status] AS [Status],
[Project1].[ShiftId] AS [ShiftId],
[Project1].[EndDateTime] AS [EndDateTime],
[Project1].[DataAreaId] AS [DataAreaId]
FROM ( SELECT
[Extent1].[Id] AS [Id],
[Extent1].[WorkCentreId] AS [WorkCentreId],
[Extent1].[WorksOrderId] AS [WorksOrderId],
[Extent1].[Operator] AS [Operator],
[Extent1].[BookingDate] AS [BookingDate],
[Extent1].[StartTime] AS [StartTime],
[Extent1].[Duration] AS [Duration],
[Extent1].[TotalProduced] AS [TotalProduced],
[Extent1].[RejectQty] AS [RejectQty],
[Extent1].[Item] AS [Item],
[Extent1].[Mould] AS [Mould],
[Extent1].[BatchCode] AS [BatchCode],
[Extent1].[Complete] AS [Complete],
[Extent1].[Status] AS [Status],
[Extent1].[ShiftId] AS [ShiftId],
[Extent1].[EndDateTime] AS [EndDateTime],
[Extent1].[DataAreaId] AS [DataAreaId]
FROM [dbo].[vw_BookingHistory] AS [Extent1]
WHERE [Extent1].[WorkCentreId] = @p__linq__0
) AS [Project1]
ORDER BY [Project1].[EndDateTime] DESC',N'@p__linq__0 nvarchar(4000)',@p__linq__0=N'QK0009'