File tree Expand file tree Collapse file tree 4 files changed +19
-13
lines changed
.blueprint/generate-sample/templates/samples/jdl-default
blazor/templates/src/client/Project.Client/Models Expand file tree Collapse file tree 4 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,9 @@ enum Language {
6060 FRENCH, ENGLISH, SPANISH
6161}
6262
63-
63+ relationship OneToOne {
64+ Employee{internalUser(login)} to User with builtInEntity
65+ }
6466
6567relationship OneToOne {
6668 Country{region} to Region
Original file line number Diff line number Diff line change @@ -86,6 +86,10 @@ relationship OneToOne {
8686 Department{location} to Location
8787}
8888
89+ relationship OneToOne {
90+ Employee{internalUser(login)} to User with builtInEntity
91+ }
92+
8993// defining multiple OneToMany relationships with comments
9094relationship OneToMany {
9195 Employee to Job{employee},
Original file line number Diff line number Diff line change @@ -63,22 +63,14 @@ public class <%= asModel(entityClassName) %> : BaseModel<<%= primaryKeyType %>>
6363 const otherEntityNamePascalized = relationships[idx].otherEntityNamePascalized ;
6464 const relationshipFieldNamePascalizedPlural = relationships[idx].relationshipFieldNamePascalizedPlural ;
6565 const relationshipFieldNamePascalized = relationships[idx].relationshipFieldNamePascalized ;
66- if (relationshipType === ' one-to-one' ){
67- if (otherEntityNamePascalized === ' User' ) { _% >
68- public string UserId { get; set; }
69- < % _ } else { _% >
66+ if (relationshipType === ' one-to-one' ) { _% >
7067 public < %= getPrimaryKeyType (relationships[idx].otherEntity ) % > < %= relationshipFieldNamePascalized % > Id { get; set; }
7168 < % _ }
72- }
7369 if (relationshipType === ' one-to-many' ) { _% >
7470 public IList<< %= asModel (otherEntityNamePascalized) % >> < %= relationshipFieldNamePascalizedPlural % > { get; set; } = new List << %= asModel (otherEntityNamePascalized) % >> ();
7571 < % _ } else if (relationshipType === ' many-to-one' ) {
7672 if (relationshipRequired) { _% >
7773 [Required]
78- < % _ }
79- if (otherEntityNamePascalized === ' User' ) { _% >
80- public string UserId { get; set; }
81- < % _ } else { _% >
8274 public < %= getPrimaryKeyType (relationships[idx].otherEntity ) % > < %= relationshipFieldNamePascalized % > Id { get; set; }
8375 < % _ }
8476 } else if (relationshipType === ' many-to-many' ) { _% >
Original file line number Diff line number Diff line change @@ -122,12 +122,20 @@ export default class extends BaseApplicationGenerator {
122122
123123 get [ BaseApplicationGenerator . PREPARING_EACH_ENTITY ] ( ) {
124124 return this . asPreparingEachEntityTaskGroup ( {
125+ /*async prepareUserEntity({ application, entity }) {
126+ if (entity.name === 'User') {
127+ application.user.primaryKey.type = equivalentCSharpType(application.user.primaryKey.type);
128+ //TODO : improve and use user entity
129+ }
130+ },*/
125131 async preparingTemplateTask ( { application, entity } ) {
126132 // This assumes we aren't using value objects and every entity has a primary key
127133 const idField = entity . fields . filter ( f => f . id ) [ 0 ] ;
128-
129- entity . primaryKeyType = entity . databaseType === 'mongodb' ? 'string' : equivalentCSharpType ( idField . fieldType ) ;
130-
134+ if ( entity . name === 'User' ) {
135+ entity . primaryKeyType = 'string' ;
136+ } else {
137+ entity . primaryKeyType = entity . databaseType === 'mongodb' ? 'string' : equivalentCSharpType ( idField . fieldType ) ;
138+ }
131139 entity . dotnetEntityModel = `${ entity . entityClass } ${ application . modelSuffix } ` ;
132140 entity . pascalizedEntityClass = toPascalCase ( entity . entityClass ) ;
133141 entity . pascalizedEntityClassPlural = toPascalCase ( entity . entityClassPlural ) ;
You can’t perform that action at this time.
0 commit comments