Я новичок в .net полностью, и мне просто нужно знать синтаксис или возможные функции для добавления в мой оператор if, чтобы проверить, является ли <% If Model.contacts Is Null Then%>
неправильным.
Где Model.contacts
происходит из моей ClientViewModel, а Model.contacts
имеет тип System.Linq.IQueryable(Of Contact)
Вот код для адресов ...
<% If Model.addresses Is Nothing Then %>
<table class="edit">
<tr>
<td>
There are no Addresses associated with this Client, click the 'Create' Button to add contacts.
</td>
</tr>
</table>
<% Else%>
<table class="child">
<tr>
<th>
Actions
</th>
<th>
Street
</th>
<th>
City
</th>
<th>
State
</th>
<th>
Country
</th>
<th>
Zip
</th>
</tr>
<% For Each item In Model.addresses%>
... shows more table rows...
<% Next%>
</table>
<% End If%>
И он выводит только заголовки с несколькими строками таблицы из оператора For Each
альтернативный текст http://a.imageshack.us/img205/236/shotji.jpg
А вот как мы получаем Model.addresses из ClientViewModel
Public Class ClientViewModel
Private _this_client As Client
Private _these_contacts As System.Linq.IQueryable(Of Contact)
Private _these_addresses As System.Linq.IQueryable(Of Address)
Private _these_statuses
Sub New(ByVal this_client As Client, ByVal these_contacts As System.Linq.IQueryable(Of Contact), ByVal these_addresses As System.Linq.IQueryable(Of Address), ByVal these_statuses As System.Collections.IEnumerable)
_this_client = this_client
_these_contacts = these_contacts
_these_addresses = these_addresses
_these_statuses = these_statuses
End Sub
Public ReadOnly Property contacts As System.Linq.IQueryable(Of Contact)
Get
Return _these_contacts
End Get
End Property
Public ReadOnly Property addresses As System.Linq.IQueryable(Of Address)
Get
Return _these_addresses
End Get
End Property
Шаблон
<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage(Of TotallyAwesomeCRM.ClientViewModel)" %>
List item