AutoMapper.AutoMapperMappingException:'错误映射类型。

时间:2018-07-05 13:54:17

标签: exception guid

我收到此Guid异常。有人可以帮我吗 内部异常: FormatException:Guid应该包含32个数字和4个破折号(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。 我正在使用以下代码:

public override Comment Save(Comment comment)
        {
            var commentDO = _mapper.Map<CommentDO>(comment);
            // todo: This contains a major flaw. What if the type method doesn't match the class name?
            // There are no checks currently
            // todo: Move to a factory method or a builder method
            commentDO.Type = commentDO.GetType().ToString();
            commentDO.Id = Guid.NewGuid().ToString();
            Trace.TraceInformation($"Inserting new activity with id[{commentDO.Id}]");
            DbUtil.Client.CreateDocumentAsync(CollectionUri, commentDO);
            comment = _mapper.Map<Comment>(commentDO);
            return comment;
        }

0 个答案:

没有答案