C# ABP中实体的DTO映射异常
我在尝试插入实体时遇到一个关于“映射”的错误 插入是通过CRUDAPService的C# ABP中实体的DTO映射异常,c#,automapper,aspnetboilerplate,C#,Automapper,Aspnetboilerplate,我在尝试插入实体时遇到一个关于“映射”的错误 插入是通过CRUDAPService的Create方法进行的。 我的实体继承自FullAuditedEntity,但相关的DTO只指定了几个属性 我如何处理这种情况 Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the s
Create
方法进行的。
我的实体继承自FullAuditedEntity
,但相关的DTO只指定了几个属性
我如何处理这种情况
Unmapped members were found. Review the types and members below.
Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type
For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters
==========================================================================
PostDto -> Post (Destination member list)
MaiPiuSprechi.Domain.Posts.Dto.PostDto -> MaiPiuSprechi.Domain.Posts.Post (Destination member list)
Unmapped properties:
Items
IsDeleted
DeleterUser
DeleterUserId
DeletionTime
CreatorUser
LastModifierUser
LastModificationTime
LastModifierUserId
CreationTime
CreatorUserId
我的DTO:
[AutoMapFrom(typeof(Post))]
public class PostDto : EntityDto
{
[Required]
public string Description { get; set; }
public string Note { get; set; }
public DateTime? Scadenza { get; set; }
[Required]
public string Zona { get; set; }
public TipoPost Tipo { get; set; }
}
我的实体:
[Table("AbpPosts")]
public class Post : FullAuditedEntity<int,User>
{
public Post()
{
// CreationTime = DateTime.Now;
}
public Post(string description, string zona)
{
Description = description;
Zona = zona;
}
public Post(string description, string zona, TipoPost tipo)
{
Description = description;
Zona = zona;
Tipo = tipo;
}
[Required]
public string Description { get; set; }
public string Note { get; set; }
public DateTime? Scadenza { get; set; }
[Required]
public string Zona { get; set; }
[NotMapped]
public virtual ICollection<Item> Items { get; set; }
public TipoPost Tipo { get; set; }
}
[表(“反对”)]
公共类职位:FullAuditedEntity
{
公职人员职位()
{
//CreationTime=DateTime.Now;
}
公开帖子(字符串描述,字符串区域)
{
描述=描述;
地带=地带;
}
公共邮政(字符串描述、字符串区域、TipoPost tipo)
{
描述=描述;
地带=地带;
Tipo=Tipo;
}
[必需]
公共字符串说明{get;set;}
公共字符串注释{get;set;}
公共日期时间?Scadenza{get;set;}
[必需]
公共字符串Zona{get;set;}
[未映射]
公共虚拟ICollection项{get;set;}
公共TipoPost Tipo{get;set;}
}
所需的映射方向:
PostDto->Post(目标成员列表)
[AutoMapFrom(typeof(Post))]
在此处配置Post->PostDto
:
[AutoMapFrom(typeof(Post))]
公共类PostDto:EntityDto
要配置两个方向,只需执行以下操作:
[AutoMap(typeof(Post))]
公共类PostDto:EntityDto
所需的映射方向:
PostDto->Post(目标成员列表)
[AutoMapFrom(typeof(Post))]
在此处配置Post->PostDto
:
[AutoMapFrom(typeof(Post))]
公共类PostDto:EntityDto
要配置两个方向,只需执行以下操作:
[AutoMap(typeof(Post))]
公共类PostDto:EntityDto
Brilliant为我节省了几个小时的时间。谢谢Brilliant帮我节省了几个小时的时间。谢谢