Timeout has elapsed for Dynamic LINQ.Contains(). Error

dynamic-linq linq-to-entities


Hello, guys
In order to export some data from a SQL 2008 database onto a vb.net 3.5 website, I'm working on this query. After the first query, I'm using dynamic linq to filter the results depending on the date, state, nation, specialization, and hospital affiliation.

Each of the filters in the query has a single value. with the exception of Hospital Affiliation, which contains a list with commas. such as OSUMC, Hospital West, and Hospital East

To check if the particular hospital is present in the comma-delimited list while filtering, I must use the.Contains command. ex: (OSUMC, HospitalWest, Hospital East). contains("OSUMC")

The query works without a hitch if I filter on Date, State, Country, and Specialty. But if I include a hospital affiliation filter that is a.Contains() filter, I start receiving timeout errors.

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

Description: The current web request encountered an unhandled error while it was being processed. To learn more about the mistake and where in the code it first appeared, please check the stack trace.

Exception Information: System.Data. SqlClient. Timeout has elapsed, SQLException. Before the action could be finished, the timeout period expired, or the server wasn't responsive.

Dim ctx As New OSUMCEntities
    Dim query = (From ca As OSUMCModel.vw_ConferenceAttendance In ctx.vw_ConferenceAttendance Select New With _
                                                                                                     { _
                                                                                                         .LastName = ca.LastName, _
                                                                                                         .FirstName = ca.FirstName, _
                                                                                                         .UserID = ca.UserID, _
                                                                                                         .UserName = ca.Username, _
                                                                                                         .Degree = ca.DegreeName, _
                                                                                                         .Specialty = ca.Specialty, _
                                                                                                         .Profession = ca.Profession, _
                                                                                                         .HospitalAffiliations = ca.HospitalAffiliations, _
                                                                                                         .Address1 = ca.MailingAddress1, _
                                                                                                         .Address2 = ca.MailingAddress2, _
                                                                                                         .City = ca.MailingCity, _
                                                                                                         .State = ca.MailingState, _
                                                                                                         .ZipPostal = ca.MailingZip, _
                                                                                                         .Country = ca.MailingCountry, _
                                                                                                         .ConferenceID = ca.ConfID, _
                                                                                                         .Title = ca.Title, _
                                                                                                         .Date = ca.StartDate, _
                                                                                                         .MaxCredits = ca.Credits, _
                                                                                                         .CreditsAwarded = ca.CreditHours, _
                                                                                                         .CreditsAssignedOn = ca.AssignedOn, _
                                                                                                         .LastUpdated = ca.LastUpdate _
    If (txtDateStart.Text <> "" And txtDateEnd.Text <> "") Then
        Dim StartDate As Date = txtDateStart.Text
        Dim EndDate As Date = txtDateEnd.Text
        query = query.Where("(Date >= @0 And  Date <=@1)", StartDate, EndDate)
    ElseIf (txtDateStart.Text <> "") Then
        Dim StartDate As Date = txtDateStart.Text
        query = query.Where("Date >= @0", StartDate)
    ElseIf (txtDateEnd.Text <> "") Then
        Dim EndDate As Date = txtDateEnd.Text
        query = query.Where("Date <= @0", EndDate)
    End If
    If (ddlState.SelectedValue <> "Export All") Then
        query = query.Where("State = @0", ddlState.SelectedValue)
    End If
    If (ddlCountry.SelectedValue <> "Export All") Then
        query = query.Where("Country = @0", ddlCountry.SelectedValue)
    End If
    If (ddlSpecialty.SelectedValue <> "Export All") Then
        query = query.Where("Specialty = @0", ddlSpecialty.SelectedValue)
    End If
    If (ddlHospitals.SelectedValue <> "Export All") Then
        Dim Hospital As String = ddlHospitals.SelectedValue
        query = query.Where("HospitalAffiliations.Contains(@0)", Hospital)
    End If
12/17/2010 11:12:14 PM

Popular Answer

Analyze the SQL Server query that Linq executes and look at the time in SQL Profiler.

12/17/2010 11:20:42 PM

Related Questions

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow