I have an error that says: Error of the underlying provider in Open, and in in innerexcepcion says:
{"Timeout value expired." The timeout period It ran out during the pre-session start phase. It is possible that the connection will time out while waiting for the server complete the login process and respond; or, at try to create several active connections. The time spent to Trying to connect to this server was: [Previous to login] initialization = 13443; link protocol = 1; [Login] initialization = 0; authentication = 34; [After the start of session] full = 4176; "}
The line of the error where it says: Dim total_listadoNoticia = list_noticia.ToList.Count
Dim list_noticia = From f In db.NOTICIA Select New With {.IdNoticia = f.IdNoticia, .TituloNoticia = f.TituloNoticia, .DescripcionNoticia = f.DescripcionNoticia, .FechaPublicacionNoticia = f.FechaPublicacionNoticia}
Dim total_listadoNoticia = list_noticia.ToList.Count ' aquí se cae
the amount of data that is listed in Count
is enough, in fact one of the attributes of the table NOTICIA
is binary (f.FotoPortada), but it is removed.
In the webconfig
I put this to solve the problem:
<httpRuntime executionTimeout="600" maxRequestLength="4194304" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />
but nothing.
This problem occurs only the first time after running the Visual Studio
, if I run it again, the error does not appear.
I would like to know how to optimize my query
of linq making it more efficient, avoiding this type of problem and if it were not possible, like giving more memory or some capacity in webconfig
or wherever to avoid this kind of problems .
complete code:
Function partialListadoNoticia(ByVal pag As Integer) As ActionResult
Using db As New BD_LOSCOPIHUESEntities1
Dim cant_filas As Integer = 5
Dim ind_pag As Integer = (cant_filas - 1) * pag
Dim l As New ListadoNoticiasViewModel
Dim listadoNoticia_q = (From noti In db.NOTICIA.Include("FOTO") Select noti Order By noti.FechaPublicacionNoticia Descending)
Dim total_listadoNoticia = db.NOTICIA.Count
Dim ultima_paginaDouble As Decimal = total_listadoNoticia / cant_filas
Dim ultima_paginaEntero As Integer = Decimal.Round(ultima_paginaDouble, 0)
If ultima_paginaDouble > ultima_paginaEntero Then
ultima_paginaEntero = ultima_paginaEntero + 1
End If
l.listadoNoticias = listadoNoticia_q.Skip(ind_pag).Take(cant_filas).ToList()
ViewData("totalListadoNoticia") = total_listadoNoticia
ViewData("ultimaPagina") = ultima_paginaEntero
ViewData("pagina_actual") = pag ' esto es para paginación
Return View(l)
End Using
End Function
In Dim total_listadoNoticia = db.NOTICIA.Count
, is where the error indicates