servicestackormlite-servicestackservicestack-autoquery

Can OrmLite specify foreign key to an attribute other than the primary key


I have a table structure where a foreign key from Employee table references something other than the primary key of the Department table. This is for historical reasons, so that's just the way it is.

This works: q.Join<Department>((e, d) => e.DepartmentId == d.DepNo);. Note that Department's primary key is Id.

Now, is there any way I could specify the join relationship (with the column name)? The reason is that I'd like to use AutoQuery's built-in IJoin<Employee,Department> thing, but that doesn't let me specify the columns to use.


Solution

  • Please see docs on Reference Conventions for how to define implicit PK and FK references.

    AutoQuery only supports implicit references, if you need more customized behavior you’ll need to create a custom AutoQuery implementation.