繁体   English   中英

Angular2扩展微风实体

[英]Angular2 Extending Breeze Entities

我正在将Angular2和Breeze元数据生成器一起使用。 我有一个人员类,我想在客户端上使用一些自定义属性扩展实体。

这是正确的方法吗?

 import { EntityBase } from '../EntityBase';
import { ProfileFaculty } from './ProfileFaculty';
import { RoadRunner } from './RoadRunner';
import { Security } from './Security';
import { ProfileStudent } from './ProfileStudent';

/// <code-import> Place custom imports between <code-import> tags
import { EcLocalDataService } from "../../common/static"
/// </code-import>

export class Person extends EntityBase {
   // Generated code. Do not place code below this line.
   personId: number;
   isActive: boolean;
   bbUserId: string;
   bbUserName: string;
   lastName: string;
   firstName: string;
   avatarLocation: string;
   goByName: string;
   mpGender: string;
   mpAffiliation: string;
   mpPaygrade: string;
   mpComponent: string;
   email: string;
   registrationComplete: boolean;
   mpInstituteRole: string;
   modifiedById: number;
   modifiedDate: Date;
   faculty: ProfileFaculty;
   roadRunnerAddresses: RoadRunner[];
   security: Security;
   student: ProfileStudent;

   /// <code> Place custom code between <code> tags
   salutation: string;
   prettyInstituteRole: string;

   constructor() {
       super();
       this.salutation = EcLocalDataService.getSalutation(this.mpPaygrade, this.mpComponent, this.mpAffiliation);
       this.prettyInstituteRole = EcLocalDataService.prettyInstituteRole(this.mpInstituteRole);
   }
   /// </code>

}

我也注意到在Temphire示例中有这段代码。 每个班都有,但我没有。 这是做什么的?

static initializer(entity: PhoneNumber) { }

这工作了。

import { EntityBase } from '../EntityBase';
import { ProfileFaculty } from './ProfileFaculty';
import { RoadRunner } from './RoadRunner';
import { Security } from './Security';
import { ProfileStudent } from './ProfileStudent';

/// <code-import> Place custom imports between <code-import> tags
import { EcLocalDataService } from "../../common/static"
/// </code-import>

export class Person extends EntityBase {
   // Generated code. Do not place code below this line.
   personId: number;
   isActive: boolean;
   bbUserId: string;
   bbUserName: string;
   lastName: string;
   firstName: string;
   avatarLocation: string;
   goByName: string;
   mpGender: string;
   mpAffiliation: string;
   mpPaygrade: string;
   mpComponent: string;
   email: string;
   registrationComplete: boolean;
   mpInstituteRole: string;
   modifiedById: number;
   modifiedDate: Date;
   faculty: ProfileFaculty;
   roadRunnerAddresses: RoadRunner[];
   security: Security;
   student: ProfileStudent;

   /// <code> Place custom code between <code> tags
   //salutation: string;
   //prettyInstituteRole: string;

   constructor() {
       super();
       //this.salutation = EcLocalDataService.getSalutation(this.mpPaygrade, this.mpComponent, this.mpAffiliation);
       //this.prettyInstituteRole = EcLocalDataService.prettyInstituteRole(this.mpInstituteRole);
   }

   get salutation():string {
       return EcLocalDataService.getSalutation(this.mpPaygrade, this.mpComponent, this.mpAffiliation)
   }

   get prettyInstituteRole(): string {
       return EcLocalDataService.prettyInstituteRole(this.mpInstituteRole);
   }

   get prettyName(): string {
       return `${this.salutation} ${this.firstName} ${this.lastName}`
   }

     /// [Initializer]
    static initializer(entity: Person) { }
   /// </code>

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM