specimen
specimen

Reputation: 1765

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.

Upvotes: 2

Views: 237

Answers (1)

mythz
mythz

Reputation: 143284

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.

Upvotes: 1

Related Questions