C#Automapper.Map方法之间有什么区别?

C#Automapper.Map方法之间有什么区别?,c#,mapping,automapper,C#,Mapping,Automapper,我的实体类: { //The Id attribute is guid autogenerated public Guid Id {get; set;} //Some attributes } { //No Id //Some attributes } 我的来源课程: { //The Id attribute is guid autogenerated public Guid Id {get; set;} //Some attributes }

我的实体类:

{
  //The Id attribute is guid autogenerated 
  public Guid Id {get; set;}
  //Some attributes
}
{
  //No Id
  //Some attributes      
}
我的来源课程:

{
  //The Id attribute is guid autogenerated 
  public Guid Id {get; set;}
  //Some attributes
}
{
  //No Id
  //Some attributes      
}
我有以下两个代码段:

    entity =  _mapper.Map(source,entity);
    UpdateAsync(entity); 
//and   
    entity =  _mapper.Map<Entity>(source);
    UpdateAsync(entity);
entity=\u mapper.Map(源,实体);
更新同步(实体);
//及
实体=_mapper.Map(源);
更新同步(实体);
当我使用第一个代码段时,程序成功运行

但是当我使用另一个
时,编译器停止并抛出异常

数据库操作预期影响1行,但实际影响0行。自加载实体后,数据可能已被修改或删除。有关理解和处理乐观并发异常的信息,请参阅。

。。。在“UpdateAsync”方法行

注意:我正在调试程序,我发现在第二种方式中,实体”变量的属性Id将生成新guid,而第一种方式则不是

那么,上述两个片段的区别是什么?


提前谢谢

很难回答这个问题。您是否查阅了关于这些方法的文档?你看过代码检查器的区别了吗?数据库与所有这些无关,你在混合苹果和橙子。检查。@将军,你能给我详细解释一下吗你在混合苹果和桔子,你是什么意思?。你能指出我遗漏了什么吗?