Best way to get view models with entity framework : <p>Suppose I have a domain model like this:</p>

<pre><code>public class Book
{
    public int ID { get; set; }
    public string Title { get; set; }
    public string Author { get; set; }
    public DateTime PublicationDate { get; set; }
    public DateTime EntryDate { get; set; }
    public string EnteredBy { get; set; }
}
</code></pre>

<p>But I want a view model to exclude some fields, like this:</p>

<pre><code>public class BookView
{
    public int ID { get; set; }
    public string Title { get; set; }
    public string Author { get; set; }
    public DateTime PublicationDate { get; set; }
}
</code></pre>

<p>There's two ways to get view models from the database. First way is this:</p>

<pre><code>List&lt;BookView&gt; views = context.Books.Where(b=&gt;b.Author=="Winston Churchill")
    .Select(b=&gt;new BookView() { ID=b.ID,Title=b.Title,Author=b.Author,PublicationDate=b.PublicationDate})
    .ToList();
</code></pre>

<p>and the second way is this:</p>

<pre><code>var results = context.Books.Where(b =&gt; b.Author == "Winston Churchill");
List&lt;BookView&gt; views = new List&lt;BookView&gt;();
foreach(var b in results)
{
    views.Add(new BookView() { ID = b.ID,Title = b.Title,Author = b.Author,PublicationDate = b.PublicationDate});        
}
</code></pre>

<p>My question is does the difference matter at all for performance? The latter would allow more separation of layers--for example the <code>Book</code> model could just be in a separate <code>Data</code> assembly that doesn't reference the view models at all. But, I wonder if the <code>Select</code> clause makes the query more efficient.</p>
