我有以下代码(数据库是SQL Server精简4.0):
Dim competitor=context.Competitors.Find(id)
当我资料这个查找方法需要300个+ MS从刚刚60的记录表中检索竞争对手。
当我改变的代码:
Dim competitor=context.Competitors.SingleOrDefault(function(c) c.ID=id)
然后竞赛者在短短的3毫秒中。
竞争对手类:
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
我定义了许多为许多关系CompetitionSubscriptions
和OpponentMeetings
使用流利的API。
该ID属性Competitor
类是由代码首先翻译成标识列在数据表(SQL Server精简4.0)主键的龙
这里发生了什么??