Mapping Entity Framework entity to dto object using select
<p>I am using Entity Framework and I am trying to map using entities to a dto object using the following code but something is going wrong:</p>

<pre><code>var fileUploads = _dbContext.FileUploads.Include("DocumentType").Include("Store");

if (jobSearchParams.DocumentTypeId != null)
{
    fileUploads = fileUploads.Where(x =&gt; x.DocumentTypeID == 6);
}

if (jobSearchParams.StoreId != null)
{
    fileUploads = fileUploads.Where(x =&gt; x.StoreID == jobSearchParams.StoreId);
}

if (!string.IsNullOrEmpty(jobSearchParams.Name))
{
    fileUploads = fileUploads.Where(d =&gt; d.Name.Contains(jobSearchParams.Name));
}

var dtos = Mapper.Map&lt;IEnumerable&lt;JobDocumentDto&gt;&gt;(documents);

var cnt = fileUploads.Count(); // 1412

var fileDocuments = fileUploads.AsEnumerable().Select(d =&gt; new JobDocumentDto
{
    DocumentID = d.ID,
    StoreID = d.StoreID,
    StoreName = d.Store.Name,
    Document = Mapper.Map&lt;DocumentDto&gt;(d),
    DocumentName = d.Name
}).ToList();

cnt  = fileDocuments.Count; // 0
</code></pre>

<p>With the <code>AsEnumerable</code> in the expression I have 0 objects after doing the select and if I remove the <code>AsEnumerable</code> I get the following error:</p>

<blockquote>
  <p>System.NotSupportedException: LINQ to Entities does not recognize the
  method 'DataManagement.DTOs.DocumentDto
  MapDocumentDto' method, and this method cannot be
  translated into a store expression</p>
</blockquote>