title: .NET Use A Related Table To Decide What Information to Show
body: <p>I have a client model a identifier model and a link model. The identifier model contains websites available for posting, client model contains clients that need a specific amount of links per month. A link object in the link model contains the Identifier ID and the Client ID. I want another view displaying a table of all the Identifier ID's that haven't been used with a Client ID's in the Link model table if this makes sense?</p>
  
  <p>Client Model:</p>
  
  <pre><code>namespace Linkofy.Models
  {
      public class Client
  {
      public int ID { get; set; }
  
      [Required]
      [Display(Name = "Client")]
      public string clientN { get; set; }
  
      [Url]
      [Display(Name = "Website")]
      public string homePage{ get; set; }
  
      [EmailAddress]
      [Display(Name = "Contact Email")]
      public string clientEmail { get; set; }
  
      [Display(Name = "Contact Name")]
      public string contName { get; set; }
  
      [Display(Name = "Monthly")]
      public int monthlyQuota { get; set; }
  
      [Display(Name = "TF")]
      public int TrustFlow { get; set; }
  
      [Display(Name = "CF")]
      public int CitationFlow { get; set; }
  
      public int RI { get; set; }
  
      public int? MJTopicsID { get; set; }
      public virtual MJTopics MJTopics { get; set; }
  
      public int UserTableID { get; set; }
      public virtual UserTable UserTable { get; set; }
  
      public virtual ICollection&lt;Link&gt; Links { get; set; }
      public virtual ICollection&lt;Status&gt; Statuss { get; set; }
  }
  }
  </code></pre>
  
  <p>Link Model:</p>
  
  <pre><code>namespace Linkofy.Models
  {
  public class Link
  {
      public int LinkID { get; set; }
  
  
      [Required]
      [Display(Name = "Linking Page")]
      public string Obdomain { get; set; }
  
  
      public int? ClientID { get; set; }
      public virtual Client Client { get; set; }
  
      [Required]
      [Display(Name = "Outbound Link")]
      public string Obpage { get; set; }
  
      [Required]
      [Display(Name = "Anchor Text")]
      public string Anchor { get; set; }
  
      [Required]
      [Display(Name = "Date Built")]
      public DateTime BuildDate { get; set; }
  
      public int IdentifierID { get; set; }
      public virtual Identifier Identifier { get; set; }
  
      public int? UserTableID { get; set; }
      public virtual UserTable UserTable { get; set; }
  
  }
   }
  </code></pre>
  
  <p>Domain Model:</p>
  
  <pre><code>public class Identifier
  {
  public enum Ltype
      {
          GuestPost, ExistingLink
      }
  
      public int ID { get; set; }
  
      [Url]
      [Required]
      [Display(Name = "Domain")]
      public string domain { get; set; }
  
      [Required]
      [Display(Name = "Contact Email")]
      [EmailAddress]
      public string contact { get; set; }
  
      [Display(Name = "Contact Name")]
      public string contactname { get; set; }
  
      [Required]
      [Display(Name = "Price")]
      public int price { get; set; }
  
      [Display(Name = "Type of Link")]
      public Ltype? type { get; set; }
  
      [Display(Name = "TF")]
      public int TrustFlow { get; set; }
  
      [Display(Name = "CF")]
      public int CitationFlow { get; set; }
  
      public int RI { get; set; }
  
      public int? MJTopicsID { get; set; }
      public virtual MJTopics MJTopics { get; set; }
  
      public virtual UserTable UserTable { get; set; }
      public int UserTableID { get; set; }
  
      public virtual ICollection&lt;Link&gt; Links { get; set; }
  }
  }
  </code></pre>
  
  <p>Model View:</p>
  
  <pre><code>@model IEnumerable&lt;Linkofy.Models.Identifier&gt;
  
  @{
  ViewBag.Title = "Index";
  }
  @section Styles {
  &lt;link href="@Url.Content("~/Styles/Index.css")" rel="stylesheet"     type="text/css" /&gt;
  }
  
  &lt;h1&gt;Domain List&lt;/h1&gt;
  
    &lt;p class="options"&gt; @Html.ActionLink("Add New", "Create")   |   @Html.ActionLink("Add Bulk", "CreateBulk") &lt;/p&gt;
  
     &lt;div class="row"&gt;
          &lt;div class="col-md-12"&gt;
  &lt;table class="table"&gt;
  &lt;tr&gt;
      &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.domain)
      &lt;/th&gt;
      &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.contact)
      &lt;/th&gt;
      &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.contactname)
      &lt;/th&gt;
      &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.price)
      &lt;/th&gt;
      &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.type)
      &lt;/th&gt;
              &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.TrustFlow)
      &lt;/th&gt;
      &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.CitationFlow)
      &lt;/th&gt;
      &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.RI)
      &lt;/th&gt;
              &lt;th&gt;
          @Html.DisplayNameFor(model =&gt; model.MJTopics.topicalTF)
      &lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
  &lt;/tr&gt;
  
  @foreach (var item in Model.Where(Model.Links.Item =&gt; item.ClientID != ViewBag.ClientID)) {
  {
  &lt;tr&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.domain)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.contact)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.contactname)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.price)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.type)
      &lt;/td&gt;
              &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.TrustFlow)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.CitationFlow)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.RI)
      &lt;/td&gt;
              &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.MJTopics.topicalTF)
      &lt;/td&gt;
      &lt;td&gt;
          @Html.ActionLink(" ", "Details", new { id=item.ID }, new {@class= "glyphicon glyphicon-home" })
          @Html.ActionLink(" ", "Edit", new { id=item.ID }, new {@class= "glyphicon glyphicon-edit" }) 
          @Html.ActionLink(" ", "Delete", new { id=item.ID }, new {@class= "glyphicon glyphicon-trash" })
      &lt;/td&gt;
  &lt;/tr&gt;
  }
  
  &lt;/table&gt;
                              &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>