I have an ASP.Net-MVC app using LinqToSql. I have a subcontracts table, a service_lines table and a mapping/link table Service_lineToSubcontracts which contains the subcontract_id and service_line_id. On the subcontract view, I'd like to list the corresponding service lines.
This works, but has a trailing comma.
<% foreach (var sls in item.Service_lineToSubcontracts)
{ %>
<%= Html.Encode(sls.service_line.service_line_name+", ") %>
<% } %>
I think I should be able to use something like String.Join(", ", item.Service_lineToSubcontracts.ToArray())
but I'm unsure of how to get the array of service_line_names.