Lets say I have this class
public class LinkingTable
{
public int PrimaryKey { get; set; }
public int LinkFk { get; set; }
public string LinkTable { get; set; }
public OtherTable OtherTable { get; set; }
}
and some other class
public class OtherTable
{
public int PrimaryKey { get; set; }
... other properties
}
The mapping would look kind of like this
LinkingTableMap() : ClassMap<LinkingTable>
{
Id(x => x.PrimaryKey);
Map(x => x.LinkFK);
Map(x => x.LinkTable);
References(x => x.OtherTable, nameof(LinkingTable.LinkFk));
}
OtherTableMap() : ClassMap<OtherTable>
{
Id(x => x.PrimaryKey);
... other mappings
}
I want to add a constraint to the OtherTable reference in LinkingTableMap. Something like
References(x => x.OtherTable, nameof(LinkingTable.LinkFk)).Where(x => x.LinkTable == "OtherTable");
The Where method obviously doesn't exist. I need to add this constraint because I might have a third table that may have duplicate primary keys. Is something like this possible?
small edit
The constraints are constants, I don't want to reference another column (which wouldn't exist)