How to fine tune FluentNHibernate's auto mapper?

前端 未结 3 1458
广开言路
广开言路 2020-12-15 13:35

Okay, so yesterday I managed to get the latest trunk builds of NHibernate and FluentNHibernate to work with my latest little project. (I\'m working on a bug tracking applica

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 14:07

    For your Id woes, you need to change the FindIdentity setting. It's covered in the automapping wiki page, although albeit briefly.

    It should go something like this:

    AutoMap.AssemblyOf() // your usual setup
      .Setup(s =>
      {
        s.FindIdentity = m => m.Name == "ID";
      });
    

    What this does is instruct the automapper to use your new lambda (m => m.Name == "ID") when trying to discover Ids. m is the property/member, and this lambda is called for each property on each entity; whichever you return true for is the id.

提交回复
热议问题