<p>Vous ne pouvez pas (et ne devriez pas pouvoir) projeter vers une entité mappée. Vous pouvez cependant projeter vers un type anonyme ou vers un <a href="http://msdn.microsoft.com/en-us/magazine/ee236638.aspx#id0080022">DTO</a> :</p>
<pre><code class="lang-auto">public class ProductDTO
{
public string Name { get; set; }
// Other field you may need from the Product entity
}
</code></pre>
<p>Et votre méthode renverra une liste de DTO.</p>
<pre><code class="lang-auto">public List<ProductDTO> GetProducts(int categoryID)
{
return (from p in db.Products
where p.CategoryID == categoryID
select new ProductDTO { Name = p.Name }).ToList();
}
</code></pre>