2

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.

specimen
  • 1,735
  • 14
  • 23

1 Answers1

1

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.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • Yeah, I was thinking maybe there were some overload of the `Reference` or `ForeignKey` attribute that could have explicitly specified it (the foreign column name), but it seems both of those always reference the primary key of the other table. It is no big problem, as I have the workaround in place. – specimen Sep 21 '21 at 07:07