Lazy loading is not working for one to many
- by Shire
Any 1-M that use the primary key of the parent table, but any 1-M that uses a different column does not work. It generates the SQL correctly, but put the value of the key into the SQL instead of the column value I want.
Example mapping:
public TemplateMap()
{
Table("IMPORT");
LazyLoad();
Id(x => x.ImportId).Column("IMPORT_ID").GeneratedBy.Assigned();
Map(x => x.ImportSetId).Column("IMPORTSET_ID");
HasMany(x => x.GoodChildren)
.Access.CamelCaseField()
.KeyColumns.Add("IMPORT_ID")
.Cascade.Delete()
.Inverse();
HasMany(x => x.BadChildren)
.Access.CamelCaseField()
.KeyColumns.Add("IMPORTSET_ID")
.Cascade.Delete()
.Inverse();
}
Lazy loading works for GoodChildren, but not for BadChildren.
The SQL statement is correct for both children. But the wrong values are use. If the value of IMPORT_ID is 10 and the value of IMPORTSET_ID is 12. The value 10 will be used for the IMPORTSET_ID in the SQL for BadChildren instead of 12.
Anyone have any ideas what I need to change to get BadChildren to work correctly?
Note:
GoodChildren links to IMPORT_ID on Template
BadChildren links to IMPORTSET_ID on Template