0
List<Models.ViewModels.GetCVList_ViewModel> list = _context.Can_CVs
  .Where(x => x.isDeleted == false)
  .Select(x => new GetCVList_ViewModel { x.Title, x.CVID, x.CityID, x.EditDate, x.AddDate })
  .ToList();

this code I'm using the CV tables specific column to list. but column types are different so I can't

how can I do? thanks

Red
  • 2,728
  • 1
  • 20
  • 22
sedat
  • 3
  • 1
  • did you read this article ? [How do I implement IEnumerable](http://stackoverflow.com/questions/11296810/how-do-i-implement-ienumerablet) –  Dec 16 '15 at 10:25
  • ok reading now thx Dindarkdevil – sedat Dec 16 '15 at 10:26
  • public class GetCVList_ViewModel { public string Title {get; set;} public int CVID { get; set; } public short? CityID { get; set; } public DateTime? EditDate { get; set; } public DateTime AddDate { get; set; } } – sedat Dec 16 '15 at 10:28

1 Answers1

1

you should assing each model property to corresponding viewmodel propety:

.Select(x => new GetCVList_ViewModel
{ 
    Title = x.Title,
    CVID = x.CVID,
    CityID = x.CityID,
    EditDate = x.EditDate,
    AddDate = x.AddDate
})
Gene R
  • 3,684
  • 2
  • 17
  • 27