EF - not supported in LINQ to Entities
<p>I am trying to list some food items with a controller. I use Repository pattern with UnitOfWork for the data in another assembly and referenced it in a BaseApiController. The <strong>Data</strong> property is my UnitOfWork instance.</p>

<pre><code>var result = Data.Food
            .FindAll()
            .Select(FoodItemViewModel.Create);

return result;
</code></pre>

<p>and here is my ViewModel:</p>

<pre><code>public static Expression&lt;Func&lt;FoodItem, FoodItemViewModel&gt;&gt; Create
    {
        get
        {
            return fi =&gt; new FoodItemViewModel
            {
                Id = fi.Id,
                Description = fi.Description,
                DiaryEntries = fi.DiaryEntries
                .Select(s =&gt; new DiaryEntityViewModel()
                {
                    Id = s.Id,
                    Quantity = s.Quantity
                }
            };
        }
    }
</code></pre>

<p>But all I get is:</p>

<blockquote>
  <p>"The specified type member 'DiaryEntries' is not supported in LINQ to
  Entities. Only initializers, entity members, and entity navigation
  properties are supported."</p>
</blockquote>

<p>My DiaryEntries member in the ViewModel is </p>

<pre><code>IEnumerable&lt;DiaryEntityViewModel&gt;
</code></pre>

<p>and my DiaryEntries member in the Data instance is </p>

<pre><code>IRepository&lt;DiaryEntry&gt;
</code></pre>

<p>and DiaryEntry is my model class</p>

<p>and here is my FoodItem model class:</p>

<pre><code>public class FoodItem
    {
        private IEnumerable&lt;Measure&gt; measures;
        private IEnumerable&lt;DiaryEntry&gt; diaryEntries;

        public FoodItem()
        {
            this.measures = new HashSet&lt;Measure&gt;();
            this.diaryEntries = new HashSet&lt;DiaryEntry&gt;();
        }

        public int Id { get; set; }

        public string Description { get; set; }

        public virtual IEnumerable&lt;DiaryEntry&gt; DiaryEntries
        {
            get
            {
                return this.diaryEntries;
            }
            set
            {
                this.diaryEntries = value;
            }
        }

        public virtual IEnumerable&lt;Measure&gt; Measures
        {
            get
            {
                return this.measures;
            }
            set
            {
                this.measures = value;
            }
        }
    }
</code></pre>