I have defined a method defined in AppService file, Signature of method is public PagedResultDto<FetchData> GetSearchData(FetchDataInput searchInput)
. I'm calling this method from Angular code, but service-proxoes.ts
file has generated method in which I need to pass all the parameters one by one.
public class FetchDataInput: PagedAndSortedInputDto, IShouldNormalize
{
public int DataLevel { get; set; }
public int DataType { get; set; }
public string DataCode { get; set; }
public string DescLong { get; set; }
public string LanguageCode { get; set; }
public string DataParent { get; set; }
public void Normalize()
{
if (string.IsNullOrEmpty(Sorting))
{
Sorting = "DataCode";
}
}
}
Service-Proxies.ts file:
getSearchData(dataLevel: number, dataType: number, dataCode: string, descLong: string, languageCode: string, dataParent: string, sorting: string, maxResultCount: number, skipCount: number): Observable<PagedResultDtoOfFetchData> {
So I have to call the getSearchData
method by the following way.
this._dataService.getSearchData(AppConsts.dataLevelType, undefined, undefined,
undefined, this.currentLanguage.name, undefined, undefined, undefined, undefined).subscribe((result) => {
//result.items;
});
So I have to pass all the parameters, but if let's say there are 100 parameters, it will be error prone and not good programming style. So it has to take a class object that's it. So is there any way to do the this?
You can create a object to store those parametter like this:
...And in the getSearchData, tried to serialize the model and pass it to your api: