.
Wrapper , Count, .
:
public class ItemWithCount
{
public Item Item { get; set; }
public int Count
{
get { return Item.Count; }
set { Item.Count = value; }
}
}
:
var ret = (from item in contex.Items
select new ItemWithCount
{
Item = item,
Count = item.refToAnotherEntity.Count()
}).AsEnumerable().Select(x => x.Item);
2 , , Count . - :
var ret = (from item in contex.Items
select new
{
Item = item,
Count = item.refToAnotherEntity.Count()
});
Parallel.ForEach(ret, x => x.Item.Count = x.Count);
var results = ret.Select(x => x.Item);
, althouth , ... ?