Lazy loading is not working for one to many

Posted by Shire on Stack Overflow See other posts from Stack Overflow or by Shire
Published on 2010-05-14T21:24:16Z Indexed on 2010/05/14 21:34 UTC
Read the original article Hit count: 251

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET