How to use an Id generator with JoinedSubclassMapping

39 Views Asked by At

With a ClassMapping, I could do this:

public class FooMap: ClassMapping<Foo>
{
    public FooMap()
    {
        Table("FOO");
        Id(x => x.Id, x =>
        {
            x.Column("ID");
            x.Generator(Generators.HighLow,
                g => g.Params(new
                    { table = "HI_LO", where = "table_name = 'FOO'", max_lo = 1000 }));
        });
    }
}

Now I've moved parts of Foo to BaseFoo in the database and want to use a table per class approach.

However, this is not valid:

public partial class FooMap: JoinedSubclassMapping<Foo>
{
    public FooMap()
    {
        Table("FOO");
        // Id(...) Cannot resolve symbol
    }
}

I expected to find a way to apply a hilo generator on a JoinedSubclassMapping but despite research and many attempts I can't figure out a workaround.

Update: I ended up putting the HiLo generated id on the parent class, I initially thought this would not suit my needs but it did.

0

There are 0 best solutions below