title: How to Cast a IQueryable/IEnumerable result to a custom Model C# EntityFramework
body: <p>Lets say that I have a Repository with this function </p>
  
  <pre><code>public async Task&lt;IEnumerable&lt;Contacts&gt;&gt; GetAll()
   {
       return await _context.Contacts.ToListAsync();
   }
  </code></pre>
  
  <p>Where the Contacts Entity is the same one returning the call. But I didn't want to use the same class because there's some fields that I like to keep out of the call. There's any way that I could "mirror" a second model called "ContactsModel" to return the data without using Anonymous calls like :</p>
  
  <pre><code>var result = context.t_validation.Where(a =&gt; a.isvalidated == 10).Select(x =&gt; new
                  {
                      x.date_released,
                      x.utoken,
                      x.Images,
                      x.images_key,
                      x.Type
                  });
  </code></pre>
  
  <p>Of putting into a loop and passing to this new Model :</p>
  
  <pre><code>foreach (var item in list)
                  {
                      decp.Add(new ValidationModel
                      {
                          uToken = item.utoken,
                          Date = item.date_released,
                          Images = bc.Decrypt(item.Images, item.images_key),
                          Type = item.Type
                      });
                  }
  </code></pre>
  
  <p>Thanks!</p>