title: Using the ADO.NET Entity Framework to access one object from another
body: <p>I have the following code:</p>
  
  <pre><code>using (var db = new IntDB())
  {
      var subscription =
          (from s in db.Subscription
           where s.SubsciptionId == subscriptionId
           select s).FirstOrDefault();
      if (subscription != null)
      {
          db.DeleteObject(subscription);
          db.SaveChanges();
  
          EntityKeyMember articleId = (EntityKeyMember)subscription.ArticleReference
                                   .EntityKey.EntityKeyValues.GetValue(0);
          var article = (from a in db.Article
                         where a.ArticleId == (int)articleId.Value
                         select a).FirstOrDefault();
          if (!String.IsNullOrEmpty(article.WebUrl) &amp;&amp; article.WebUrl.Equals(@"/ExploderLists"))
          {
              var lstAppIntrfc = new ListAppInterface();
              // the articleId is stored in the entity key here, the article object hasn't been instanicated
              // so it's easier to just get it from the EntityKey.                            
              lstAppIntrfc.RemoveEmailFromListByArticleID((int)articleId.Value, subscription.EmailAddress);
          }
      }
  }
  </code></pre>
  
  <p>and here's my question. After I load the <code>Subscription</code> object with the LINQ code, I find that the <code>Article</code> property of the subscription instance is NULL! I can find the <code>entityKey</code> for the article in the subscription instance, but I have to then run LINQ to load the article instance that I need for the final IF statement there.</p>
  
  <p>Have I just gone totally off the reservation here and I am not understanding how to use the entity objects or is this the only way to do this?</p>