Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow access to service provider on ConfigureODataClient #28

Open
weitzhandler opened this issue Mar 30, 2020 · 5 comments
Open

Allow access to service provider on ConfigureODataClient #28

weitzhandler opened this issue Mar 30, 2020 · 5 comments

Comments

@weitzhandler
Copy link

weitzhandler commented Mar 30, 2020

Hi,

I have a tenant app that has various services that provide information about the current tenant, user, and the URLs to be used to access server resources, per tenant/user.
It's called IUriProvider.

I can see the method in DefaultODataClientFactory based on serviceRoot.
But I rather them all to be based on the underlying IHttpClientFactory's provided HttpClient.BaseAddress.

In addition, the IOdataClientFactory.CreateClient<T>, also requires a serviceRoot argument. This is unnecessary if it has already been configured, or if there is an underlying HttpClient whose BaseAddress should be used for this matter instead.
Asking for Uris all over the place which would rely on constants, is a bad habit and somewhat defies the power of DI.

@weitzhandler
Copy link
Author

This code:

public class PeopleController : ODataController
{
    private readonly IODataClientFactory _clientFactory;

    public PeopleController(IODataClientFactory clientFactory)
    {
        _clientFactory = clientFactory;
    }

    [EnableQuery]
    public IEnumerable<Person> Get()
    {
        var client = _clientFactory.CreateClient<DefaultContainer>();
        var people = client.People.Execute();
        return people;
    }
}

Does not work.
There is no overload of CreateClient that can take care of the serviceUri parameters on its own.
Please address this.

@dotdiego
Copy link

dotdiego commented Jul 8, 2021

Hello,

Has this problem been adressed ?

We can see that in the documentation https://docs.microsoft.com/en-us/odata/client/using-extensions#named-clients

You allow configuration of the CreateClient within the Startup.cs but no constructor exists for CreateClient that takes no parameter

@Schoof-T
Copy link

How has this not been resolved yet? This seems like such a strange oversight, how does everyone else work around this?

@erizet
Copy link

erizet commented Feb 13, 2023

I have the same question too. Any new input?

@se-andbjo
Copy link

I'm facing the same issue, any news on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants