0
この質問はasked alreadyでしたがまともな答えはありませんでした。代わりにId
を探しているのそれはProductId
ために見えるように流暢なnhibernateプロパティ名のためのPrimaryKeyConvention
は流暢NHibernateのためのプロパティ名規則はありますか?
PrimaryKeyConvention
は、データベースの列名に適用され、プロパティ名には適用されません。 FluentNHibernate.Visitors.ValidationException
:Idがマッピングされたエンティティ '製品' を持たないで
public class Product { public int ProductId { get; set; } public string Name { get; set; } } public class AutomappingConfiguration : DefaultAutomappingConfiguration { public override bool ShouldMap(Type type) { bool shouldMap = type.In(typeof(Product)); return shouldMap; } } public void TestFluentNHibernate() { var configuration = Fluently.Configure(). Database(MsSqlConfiguration.MsSql2008.ConnectionString("database=asd;server=.\\sqlexpress;trusted_connection=true;")) .Mappings(m => { IAutomappingConfiguration cfg = new AutomappingConfiguration(); m.AutoMappings.Add(AutoMap.AssemblyOf<Product>(cfg).Conventions.AddFromAssemblyOf<PrimaryKeyConvention>()); }); var factory = configuration.BuildSessionFactory(); }
結果:
は、このシナリオを考えてみましょう。 IDプロパティをマップするには、Idメソッドを使用します。例:Id(x => x.Id)。
流暢なnhibernateがプロパティ名の「EntityName」+「Id」を探すためにどのような規則を追加/上書きできますか?私はthisの大会のページを見てきましたが、上書きすることはできません。