I have an EntityManager in a Singleton. For some reason, one of my queries won’t use
the client side cache. Whenever I use
SQL Profiler, I keep seeing the following query:
SELECT TOP (1)
[Extent1].[ID] AS [ID],
[Extent1].[CompanyID] AS [CompanyID],
[Extent1].[Description] AS [Description]
FROM
[dbo].[tblGLAccountTypes] AS [Extent1]
INNER JOIN [dbo].[tblPvxCompanies] AS [Extent2] ON
[Extent1].[CompanyID] = [Extent2].[ID]
WHERE (1 = [Extent2].[Organization]) AND (9 =
[Extent1].[ID])
Stepping through the code, I can see exactly when it is
being called. It’s being called on the
last line of the following code:
Public Overrides Sub LoadRecord(ByVal em As EntityManager,
ByVal ID As Long)
Dim emg As
EntityManager_GL = DirectCast(em, EntityManager_GL)
Dim item =
(From queryItem In emg.efGLAccountTypes
Where
queryItem.ID = ID
Select
queryItem).FirstOrNullEntity
My original theory was that it was because of the
DirectCast, but I’ve got other code that does the same casting and seems to
work. My other theory is I have setup a
FilterQuery setup in my BOS code like this:
Protected
Overrides Function FilterQuery() As Boolean
QueryFilters.AddFilter(Of DomainModel.emGL.efGLAccountType)(Function(q)
q.Where(Function(c) c.efPvxCompany.efOrganization.ID = organzationId))
Return
MyBase.FilterQuery()
End Function
Does adding a filterquery negate the client side cache? Is there a way to change that? I sort of assume the logic would be, if you
retrieved the value in the past, the value should still be cached.