Getting a single entity by Key
Closed this issue · 2 comments
buchatsky commented
Expected behavior
Getting a single entity from OData service by its key:
export class NorthwindContext extends ODataService {
constructor() { super('api/'); }
get products(): IODataQuery<Product> { return this.createQuery<Product>('products'); }
get orderDetails(): IODataQuery<OrderDetail> { return this.createQuery<OrderDetail>('orderDetails'); }
}
/* single key */
/* api/products(3) */
let productId: number = 3;
let product: Product = await this.context.products
.byKey(productId)
.singleAsync();
/* composite key */
/* api/orderDetails(orderId=10527,productId=4) */
let orderId: number = 10527, productId: number = 4;
let orderDetail: OrderDetail = await this.context.orderDetails
.byKey({ orderId, productId })
.singleAsync();
Actual behavior
Using .where clause which produces urls like "api/products?$filter=productId eq 3" and causes calling a general Get() method on the server which returns a collection of a single entity
jinqu-odata version: 1.1.3
umutozel commented
I think we can close this now because I've merged the PR