I currently have a View in MVC where I pass a single set of data to the view. However, I've come across a problem where I am having to use a LINQ query within a For Each loop in the View to pull out additional information from a SQL View of data from another DB.
The error I'm getting is Late binding operations cannot be converted to an expression tree.
The particular snippet I'm encountering the error on is:
<%
For Each oCall In ViewData.Model
%>
<tr>
<td width="290"><a href="/Calls/Details/<%=oCall.CallID %>"><%=oCall.CallSubject %></a></td>
<td width="140"><%=oCall.CallReference %></td>
<td width="130"><%=oCall.CallType.CallTypeName %></td>
<td width="150"><%=oCall.DateOpened %></td>
<%
Dim assigned As String
Dim db As New CustomerServicesModelDataContext
Dim tStore = (From a In db.vStores _
Where a.CompanyID = oCall.CompanyID _
And a.StoreNumber = oCall.StoreID _
Select a).SingleOrDefault()
assigned = tStore.Store
%>
<td width="175">
<%= assigned%>
</td>
</tr>
<%
Next
%>
The error happens twice. First on oCall.CompanyID and then on oCall.StoreID.
Have I missed something?
Thanks for any help in advance.