En mi aplicación, intento mostrar una lista de elementos. Para esto, tengo que hacer una llamada get
con 2 parámetros al back-end. Obtengo una referencia nula en Visual Studio cuando abro la página. Aquí está el código. Hasta ahora he hecho esto, pero no sé cómo solucionar el error. ¿Qué debo hacer para arreglarlo?
Servicio TS:
getWorkItemStockTransactionList(filter: IFilter): Observable<IStockTransaction[]> { return this._httpOrder.get('Order/GetWorkItemStockTransactionList/'+ filter); }
TS:
transactionList: IStockTransaction[] = []; private _selectedWorkItem: IWorkItem; Filter: IFilter; @Input() set StockTransaction(prm: IWorkItem) { if (this._selectedWorkItem != prm) { this._selectedWorkItem = prm; this.dataSource = new MatTableDataSource(this.transactionList); this.getWorkItemStockTransactionList((this._selectedWorkItem.Product.ProductId) , (this.Order.OrderId)); } } @Input() Order: IOrder; getWorkItemStockTransactionList(productId , orderId) { this._orderService .getWorkItemStockTransactionList(this.Filter) .subscribe((response: IStockTransaction[]) => { this.dataSource = new MatTableDataSource(response); this.transactionList = response; }); }
back-end:
[HttpGet] public List<DtoStockTransaction> GetWorkItemStockTransactionList(DTOFilter dTOFilter) { return StockSpProvider.GetWorkItemStockTransactionList(dTOFilter); } public static List<DtoStockTransaction> GetWorkItemStockTransactionList(DTOFilter prm) { //this is where I get the error SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ProductId",prm.Product.ProductId), new SqlParameter("@OrderId",prm.Order.OrderId) }; ... }