simple-odata-client / Simple.OData.Client

MIT License
330 stars 196 forks source link

Multiple Filter calls do not work together #442

Open dibonium opened 6 years ago

dibonium commented 6 years ago

This issue was originally reported here: https://github.com/object/Simple.OData.Client/issues/78

However I have been using version 4.29 and when I chain Filter calls only the last call is put into the request.

In my case the first Filter call uses the string overload while the second filter call uses the Linq.Expressions

var stringOrFilter = this.BuildStringOrFilter(); //"((guidField eq guidValue1) or (guidField eq guidValue2))" var entity = await client .For() .Filter(stringOrFilter) .Filter(f => f.IsField1 == false || f.IsField1 == null) .FindEntriesAsync();

The request that is sent according to Fiddler only contains the conditions from the last filter call and does not have my stringOrFilter conditions included

banderson501 commented 6 years ago

I would also find this useful to handle the case of matching a field against a list of possible values.

object commented 6 years ago

@dibonium I am not able to reproduce this issue using latest library version (5.3). Here's the test I added:

    [Fact]
    public async Task CombinedConditionsWithMultipleFilters()
    {
        var client = new ODataClient(CreateDefaultSettings().WithHttpMock());
        var employee = await client
            .For<Employee>()
            .Filter(x => x.FirstName == "Nancy")
            .Filter(x => x.HireDate < DateTime.Now)
            .FindEntryAsync();
        Assert.Equal("Davolio", employee.LastName);
    }

I can see that the correct URL is generated, combining both conditions. Can you verify this?

agmohit92 commented 4 years ago

Happening when I'm using string overload of Filter along with any other overload of Filter Method. @object