もっとコードを見ないと、確かなことは言えませんが、製品から名前と価格だけを選択したい場合は...
List<ProductEntity> productList;
productList = product.getProducts()
.Select(p => new { p.Name, p.Price });
編集:私のコード例を拡張して、動作中のテストを表示します:
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace StackOverflow
{
[TestFixture]
public class ProductListQuestion
{
class ProductEntity
{
public string Name { get; set; }
public decimal Price { get; set; }
public string OtherProperty { get; set; }
}
[Test]
public void CanSelectProperties()
{
var products = new List<ProductEntity>
{
new ProductEntity {Name = "First", Price = 1M},
new ProductEntity {Name = "Second", Price = 2M},
new ProductEntity {Name = "Third", Price = 3M}
};
var productList = products
.Select(p => new { p.Name, p.Price });
Assert.That(productList, Is.Not.Null);
Assert.That(productList.Count(), Is.EqualTo(3));
Assert.That(productList.ElementAt(0), Has.No.Property("OtherProperty"));
Assert.That(productList.ElementAt(0), Has.Property("Name"));
}
}
}