We are currently re-writing our application and we have hundreds of tables and each of them has a CreatedById and ModifiedById and each of these has a foreign key to our users table, around 411 FKey / Nav properties to that table.
We use DevForce and EF for our DB access / entity management and during some testing of migration from our current application to this new one we are getting errors / stack overflows in the serializer and / or extremely long load times (5 seconds for 2000 entities).
I created a test app that had the same number of tables but removed all 411 of those FKeys and it dropped the load to under a second and the serialization errors also went away.
The issue I now have is I do actually need to get to the users table from a number of other entities using dot navigation / nav props so I was wondering if anyone knows how to add these to the buddy class via code.
I have googled and did find an old DevForce forum post that mentions something about some sample code to do this but there was no link to the actual sample.
If anyone has any ideas / suggestions I would really appreciate it.
Thanks in advance
I'm curious why you're seeing the serialization errors and poor load time. If you have the time, please open a support case at the DevForce support site with additional information so we can take a look at it.
The simplest approach to adding hand-coded navigation properties is to use the fact that the entity classes are partial classes. The "buddy" class is intended more to provide overrides for property attributes so isn't a good fit here.
To hand-code a navigation property, a simple example (without validation) could look something like this:
The problem here is that you have hundreds of entity classes which need these properties, so implementing these on a base entity class which your other entities extend would be a good idea. The DevForce Resource Center has more information on using a base entity class.
Another option is to override the template generation to generate custom properties on each entity. The DRC also has some information on this.