我怎样才能转换IEnumerable<Category>
成IEnumerable<CategoryViewModel>
这个定义
public class Category
{
public Guid Id { get; set; }
public string Name { get; set; }
public DateTime CreationTime { get; set; }
}
public class CategoryViewModel
{
public Guid CategoryId { get; set; }
public string Name { get; set; }
}
我已经这样做了
public static IEnumerable<CategoryViewModel> ConvertToCategoryViewModelList(this IEnumerable<Category> category)
{
return Mapper.Map<IEnumerable<Category>, IEnumerable<CategoryViewModel>>(category);
但它不会将 Id 映射到 CategoryId 并且我不想在 CategoryVeiwModel 中有 CreationTime