I have the following code (SQL Server Compact 4.0 database):
Dim competitor=context.Competitors.Find(id)
When I look at this, the Find method takes 300 + ms to retrieve the member from the table for a total of 60 records.
When I change the code to:
Dim competitor=context.Competitors.SingleOrDefault(function(c) c.ID=id)
Then the competitor is in just 3 ms.
Competitor Class:
Public Class Competitor Implements IEquatable(Of Competitor) Public Sub New() CompetitionSubscriptions = New List(Of CompetitionSubscription) OpponentMeetings = New List(Of Meeting) GUID = GUID.NewGuid End Sub Public Sub New(name As String) Me.New() Me.Name = name End Sub 'ID' Public Property ID As Long Public Property GUID As Guid 'NATIVE PROPERTIES' Public Property Name As String 'NAVIGATION PROPERTIES' Public Overridable Property CompetitionSubscriptions As ICollection(Of CompetitionSubscription) Public Overridable Property OpponentMeetings As ICollection(Of Meeting) End Class
I have defined many-to-many relationships for CompetitionSubscriptions and OpponentMeetings using the free API.
The Competitor class ID property is Long, which is translated using the First code into the Identity column with the primary key in datatable (SQL Server Compact 4.0)
What's going on here?
entity-framework dbcontext ef-code-first sql-server-ce-4
Dabblernl Jul 27 2018-12-12T00: 00Z
source share