Closed omatrot closed 5 years ago
How can you determine the object identifier? Will property name and or type help you?
The object identifier is the combination of the column(s) of the primary key. The type and/or name are not enough.
It is in this type of situation that the extensibility of the framework really shines. What you need to do is create a class that inheritance from HbsTypeScriptEntityTypeGenerator, Then add an is-object-identifier to the data that is surfaced to the handlebars template.
Let me know if you need some assistance.
I see that I can create a class that inherits HbsTypeScriptEntityTypeGenerator but I can't see how it will be used instead of the base class. There must be some method to call in ConfigureDesignTimeServices ?
What you'll need to do is register MyHbsTypeScriptEntityTypeGenerator
in ScaffoldingDesignTimeServices
, after calling services.AddHandlebarsScaffolding
, like so:
services.AddSingleton<ICSharpEntityTypeGenerator, MyHbsTypeScriptEntityTypeGenerator>();
The code runs but now I have my properties with c# types instead of TypeScript types :|
EDIT: But I'm now able to detect primary key fields correctly :)
You need to use TypeScriptHelper
. Copy code from HbsTypeScriptEntityTypeGenerator
.
During TypeScript entities generation, I need to know if a property is part of the object identifier.
I need to tell serializr by specifiying:
Each navigation property is already always a reference.
It seems that this information may be available during csharp entities generation.
I'll be happy to make a pull request for that feature. Any further guidance would be very welcome.