【发布时间】:2019-08-25 13:32:18
【问题描述】:
我需要有关映射实体的帮助。我想连接 DAL 和 BL。我不知道如何映射集合。
DAL 中的实体团队:
namespace ICSapp.DAL.Entities
{
public class Team : ICSappEntityBase
{
public string TeamName { get; set; }
public virtual ICollection<UserTeam> Members { get; set; }
public virtual ICollection<Post> Posts { get; set; }
}
我的 BLL 模型中有相同的类。
这里是 BLL 映射器的代码:
namespace ICSapp.BL.Mapper
{
public static TeamModel MapTeamEntityToDTeamModel(Team entity)
{
return new TeamModel
{
Id = entity.Id,
TeamName = entity.TeamName,
// Members = entity.Members ??
// Posts = entity.Posts ??
};
}
public static Team MapTeamModelToTeamEntity(TeamModel model)
{
return new IngredientEntity
{
Id = model.Id,
TeamName = model.TeamName,
//Members = model.Members ??
// Posts = model Posts ??
};
}
}
那么如何映射一个集合呢? 谢谢
PS:我需要手动完成。
【问题讨论】:
标签: entity-framework mapping code-first data-access-layer