select(...names) to return IODataQuery instead of executing query
Closed this issue · 5 comments
Expected behavior
Getting an instance of IODataQuery<Pick<T, K>, TExtra> as a result of query.select(...names), in order to make a chain of query clauses in arbitrary order:
let result = await this.context.products()
.select('ProductId', 'ProductName', 'UnitPrice')
.where(p => p.UnitPrice ? p.UnitPrice > 100.00 : false)
.inlineCount()
.toArrayAsync();
Actual behavior
query.select(...names) performs a real query to the OData service and returns a Promise, so it must be the last clause in the chain.
jinqu-odata version: 1.1.3
I created a pull request in my own repository. Unfortunately I cannot create a chained PR in the original repo before my first PR is merged
Sorry for the delayed merges, I think it's best to use the PR from your repo 👍
And thanks for contributions, I find a little time to check them out, lost track of time and passed my bed time quite much
Is already made: PR
(changes to package.json are unnecessary - that was a mess with versions)
I managed to implement .select as follows:
.select(p => [p.ProductId, p.ProductName, p.UnitPrice])
PR #46
If you find it useful you can merge it too/ Again, it is close to Simple.OData.Client.
Hold on, probably this is wrong because beetle.js did allow object syntax:
.select(b => { b.Id, b.ISBN, b.Title, b.Author });
I tried it too but Typescript didn't allow me to restrict keySelector return type as Partial<T>. It complains
"Type 'void' is not assignable to type 'Partial'" It treats { } as a function body.
And array notatin does work as expected
Array notation didn't work. I think that for now it is enough with .select()