更新时间:2021-12-31 09:02:20
给你:
public class Song
{
public virtual int Id { get; private set; }
public virtual Artist Artist { get; set; }
public virtual string Title { get; set; }
public class SongMap : ClassMap<Song>
{
SongMap()
{
Id(c => c.Id);
References(c => c.Artist); // Yes, that's all.
Map(c => c.Title).Not.Nullable().Length(50);
}
}
}
话虽如此,使用 Automapper 配置更容易.
That being said, it's easier using the Automapper configuration.