加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-3 – Value Injecter是否会映射集合属性?

发布时间:2020-12-16 10:01:54 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试使用一组视图模型映射EntityFramework对象的集合. public class Channel{ public Guid Id { get; set; } public string Name { get; set; } public IEnumerableReport Reports { get; set; }}public class ChannelListViewModel{ public Guid Id {
我正在尝试使用一组视图模型映射EntityFramework对象的集合.

public class Channel
{
    public Guid Id { get; set; }

    public string Name { get; set; }

    public IEnumerable<Report> Reports { get; set; }
}

public class ChannelListViewModel
{
    public Guid Id { get; set; }

    public string Name { get; set; }

    public IEnumerable<Report> Reports { get; set; }
}

使用“报告”列表下面的代码不会被映射.我究竟做错了什么?

IList<ChannelListViewModel> viewModelList = channelList.Select(x => new ChannelListViewModel().InjectFrom(x)).Cast<ChannelListViewModel>().ToList();

解决方法

不,默认情况下,您必须使用自定义注入器.这就是我尝试使用valueinjecter后切换回自动播放器的原因. How to map lists with ValueInjector

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读