Hi,
I'm trying to implement solution of
AutoRefresh Entity Framework Data Using SQL Server Service Broker[
^] and for the entire table it is working, unfortunately, when I want to execute stored procedure with parameters using linq I get:
Unable to cast object of type 'WhereSelectEnumerableIterator`2[HP_Timer_Tool_V3.EmployeeMetricResult,System.Nullable`1[System.Decimal]]' to type 'System.Data.Entity.Infrastructure.DbQuery`1[HP_Timer_Tool_V3.EmoloyeeMetric]'.
My code:
Dim allie = (maintimer.EmoloyeeMetric(21385650, "Non-Process", "Process", "Startup", Date.Now, Date.Today))
Productivity = New AutoRefreshWrapper(Of EmoloyeeMetric)(allie.Select(Function(o) o.DayProd), maintimer, RefreshMode.StoreWins)
AutoRefresheWrapper:
Public Class AutoRefreshWrapper(Of T As Class)
Implements IEnumerable(Of T)
Implements INotifyRefresh
Private entitySet As IEnumerable(Of T)
Private _nullable As Decimal?
Private _refreshMode As RefreshMode
Public Sub New(dbq As DbQuery(Of T), dbContext As DbContext, refreshMode As RefreshMode)
Me.entitySet = dbq
DirectCast(dbContext, System.Data.Entity.Infrastructure.IObjectContextAdapter).ObjectContext.AutoRefresh(refreshMode, Me)
End Sub
If there a way to cast this object? When I was trying to materialized it with
FirstOfDefault()
then, exception was:
Value of type 'Decimal?' cannot be converted to 'System.Data.Entity.Infrastructure.DbQuery(Of HP_Timer_Tool_V3.EmoloyeeMetric)'.
Thank you for any suggestions