title: Merging 2 lists of different objects into a third list of a different type?
body: <p>I'm building an API wrapper for a third party API that translates their objects into business domain objects that can be used for other processing. In this case, I need to take 2 different objects <code>Contact</code> and <code>User</code> and merge them into a single list of objects called <code>UserContacts</code>. I'm matching these objects based on their <code>Email</code> property, and if there is no matching elements, a new one is inserted.</p>
  
  <p>Here are my current objects and methods, I'm just trying to figure out if there's a better/faster method.</p>
  
  <pre><code>public class ContactUser : IUser
  {
      public string SalesForceUserId { get; set; }
      public string SalesForceContactId { get; set; }
      public string ZendeskId { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public string Name { get; set; }
      public string Email { get; set; }
  }
  
  private List&lt;IUser&gt; MergeContactsAndUsers()
  {
      var sfContacts = SalesForceCache.Contacts.Data;
      var sfUsers = SalesForceCache.Users.Data;
  
      var newUsers = sfUsers.Select(user =&gt; new ContactUser
      {
          SalesForceUserId = user.Id, 
          Name = user.Name, 
          FirstName = user.FirstName, 
          LastName = user.LastName, 
          Email = user.Email
      }).Cast&lt;IUser&gt;().ToList();
  
      foreach (var contact in sfContacts)
      {
          var tmp = newUsers.FirstOrDefault(n =&gt; n.Email == contact.Email);
          if (tmp != null)
          {
              tmp.SalesForceContactId = contact.Id;
          }
          else
          {
              var newUser = new ContactUser
              {
                  SalesForceContactId = contact.Id,
                  Name = contact.Name,
                  FirstName = contact.FirstName,
                  LastName = contact.LastName,
                  Email = contact.Email
              };
  
              newUsers.Add(newUser);
          }
      }
  
      return newUsers;
  }
  </code></pre>