diegomvh / angular-odata

Client side OData typescript library for Angular
https://www.npmjs.com/package/angular-odata
MIT License
46 stars 14 forks source link

replacement of OdataEntityService.customCollectionAction in the latest version #83

Closed VZhangTylerTech closed 9 months ago

VZhangTylerTech commented 11 months ago

Need to know what the alternative way for the now protected customCollectionAction method. The original call is listed below; return this.customCollectionAction(entityType, body, { returnType: "Tyler.Cashiering.Business.Administration.AdministratableTenderType", responseType: "entity" }); Please provide the conversion example.

diegomvh commented 11 months ago

Hi @VZhangTylerTech

If you are using the code generator for each function/action, two functions are generated: one to create the resource and another to call the endpoint.

Here's an example of these two functions that were automatically generated in the Caso service of my application:

{
...
public crearIntervencionConRecursos(key: EntityKey<Caso>): ODataActionResource<{info: string, recursoIds: number[], requirenteIds: number[], expedienteId: number}, Intervencion> { 
  return this.entity(key).action<{info: string, recursoIds: number[], requirenteIds: number[], expedienteId: number}, Intervencion>('SIU.CrearIntervencionConRecursos');
}

public callCrearIntervencionConRecursos(key: EntityKey<Caso>, info: string, recursoIds: number[], requirenteIds: number[], expedienteId: number, options?: ODataActionOptions<Intervencion>) {
  return this.callAction<{info: string, recursoIds: number[], requirenteIds: number[], expedienteId: number}, Intervencion>(
      {info, recursoIds, requirenteIds, expedienteId}, 
      this.crearIntervencionConRecursos(key), 
      'entity', options) as Observable<ODataEntity<Intervencion>>;
}
...
}