I have a problem which I couldn't solve for two days. Here is the story.
I am fetching a list of records from my MySQL 5.0 database using LINQ to SQL, but the execution will break with an exception saying:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
I am using entity frame work code first at my back end. Here is my code:
context = new NebeContext();
var data2 = (from row in context.PollingStationConstituencyCandidates
where row.ElectionId.Equals(electionId) && row.ConstituencyId.Equals(constituencyId)
select new { row.LocationId, row.LocationNameA, row.PollingStationNameA, row.PollingStationNameE, row.PollingStationId }).Distinct();
List<PollingStationInfo> resultList = new List<PollingStationInfo>();
PollingStationInfo result = new PollingStationInfo();
foreach (var i in data2)
{
result = new PollingStationInfo() { LocationId = i.LocationId, LocationNameA = i.LocationNameA, NameA = i.PollingStationNameA, NameE = i.PollingStationNameE, PollingStationId = i.PollingStationId };
resultList.Add(result);
}
return resultList;