Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Automapper中将对象列表属性映射到另一个对象列表中?_C#_Asp.net_Entity Framework_Asp.net Core_Automapper - Fatal编程技术网

C# 如何在Automapper中将对象列表属性映射到另一个对象列表中?

C# 如何在Automapper中将对象列表属性映射到另一个对象列表中?,c#,asp.net,entity-framework,asp.net-core,automapper,C#,Asp.net,Entity Framework,Asp.net Core,Automapper,下面的讲师是一个i收集模块提供资源。讲师。如何映射到它 CreateMap<Booking, BookingResource>() .ForMember(br => br.ModuleOfferings, opt => opt.MapFrom(b => b.ModuleOfferings .Select(bm => new ModuleOfferingResource {

下面的
讲师
是一个
i收集模块提供资源。讲师
。如何映射到它

CreateMap<Booking, BookingResource>()
    .ForMember(br => br.ModuleOfferings, opt =>
        opt.MapFrom(b => b.ModuleOfferings
            .Select(bm => 
                new ModuleOfferingResource {
                    Id = bm.ModuleOfferingId,
                    SemesterId = bm.ModuleOffering.SemesterId,
                    Lecturers = ...?
                })));
public class LecturerResource
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Email { get; set; }
}

public class ModuleOfferingResource
{
    public int Id { get; set; }
    public int SemesterId { get; set; }
    public ICollection<LecturerResource> Lecturers { get; set; }

    public OfferingResource()
    {
        Lecturers = new Collection<LecturerResource>();
    }
}
public class BookingModuleOffering
{
    public int BookingId { get; set; }
    public Booking Booking { get; set; }
    public int ModuleOfferingId { get; set; }
    public ModuleOffering ModuleOffering { get; set; }
}