nhibernate / fluent-nhibernate

Fluent NHibernate!
BSD 3-Clause "New" or "Revised" License
1.66k stars 686 forks source link

Error in generated mapping when using Formula and References #715

Closed pr-okapii closed 1 month ago

pr-okapii commented 1 month ago

We where trying to map a Reference with a Formula, our code looks like

mapping.References(x => x.SomeClass).Formula("(SELECT TOP 1 a.id FROM SomeClass a WHERE a.Condition IS NULL AND a.ParentId = id)");

the resulting hbm.xml is almost right, but it adds and invalid child element "column"

<many-to-one class="Assembly.SomeClass, Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="SomeClass" formula="(SELECT TOP 1 a.id FROM SomeClass a WHERE a.Condition IS NULL AND a.ParentId = id)">
  <column name="SomeClassId" />
</many-to-one>
pr-okapii commented 1 month ago

Our mistake, an AutoMapping was adding the column