jin-qu/jinqu-odata

Add resource Decorator support for classes

Closed this issue · 1 comments

When creating a query for a class, we shouldn't have to pass the resource address.
If class is decorated, we should use that value. createQuery signature should be like this:

createQuery<T>(resource: Ctor<T> | string): LinqQuery<T>;
createQuery<T>(url: string, ctor?: Ctor<T>): LinqQuery<T>;

And we could decorate a class like this:

oDataResource('companies')
class Company {
    // ...
}

With decorators, we could add extra information for resources later.

Completed, alpha.9 package published.

Now we can decorate classes like this:

@oDataResource('Companies')
export class Company implements ICompany {
    id: number;
    name: string;
}

// 'Companies' will be queried
const result = await service.createQuery<ICompany>(Company).toArrayAsync();