wvnoort wrote:
I have a variation on this theme: I want to define a many-to-one relation between two tables using only a part of a field to join to the PK of the second table. e.g. Table 1 has a period field (YYYY-WW) and table 2 has a PK on Year.
Since there is another application (not .NET) referencing these tables that has problems with tables containing calculated fields i cannot use the obvious route of adding calculated fields to the tables.
Is there a way to use prefetch paths in this situation, or do I have to fetch the tables one after another?
There is a way in code, you can create your own EntityRelation object with the 2 fields and the code will then think they're related. Though there is a problem with the format, as the period field has a different format than the year PK.
With the EntityRelation in code, you can create your own PrefetchPathElement2 object, peek into the generated code's entity.PrefetchPathOtherEntity properties how to do it, it's pretty simple. Then simply add the node to a prefetch path and it should work. Again, if there aren't any issues with the format.