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

Add ToDictionary() and other things #19

Merged
merged 10 commits into from
Sep 23, 2019
Merged

Add ToDictionary() and other things #19

merged 10 commits into from
Sep 23, 2019

Conversation

alexandresanlim
Copy link
Collaborator

@alexandresanlim alexandresanlim commented Sep 16, 2019

Add support ToDictionary():

In some cases it is necessary to send a dictionary to url.

eg:

var odataBuilder = new ODataQueryBuilder<Core.Data.DataModels.Booking>(ODataParameter.FakeUri)
                    .For<Core.Data.DataModels.Booking>(x => x)
                    .ByList()
                    .Top(top)
                    .Skip(skip)
                    .Filter(x => x.DataItem.Description.Title == "Test")
                    .OrderBy(x => x.CreatedAt);

var dic = odataBuilder.ToDicionary();

The result is:
image

Send url with dicionary:

return await ServiceClient.InvokeApiAsync<List<Core.Data.DataModels.Booking>>("Booking/GetAllByDataStoreId", HttpMethod.Get, **dic**);

This modification does not change the ToUrl() :)

Add support Contains() text:

eg:

var uri = _odataQueryBuilder
                .For<ODataTypeEntity>(s => s.ODataType)
                .ByList()
                .Filter(s => s.ODataKind.ODataCode.Code.Contains("0") || s.ODataKindNew.ODataCode.Code.Contains("55"))
                .ToUri();

Url result:
http://mock/odata/ODataType?$filter=substringof('0',toupper(ODataKind/ODataCode/Code)) or substringof('55',toupper(ODataKindNew/ODataCode/Code))

Add support enum ToString() compare:

eg:

 var uri = _odataQueryBuilder
            .For<ODataTypeEntity>(s => s.ODataType)
            .ByList()
            .Filter(s => **s.Color.ToString() == Color.Blue.ToString()**)
            .Skip(1)
            .Top(10)
            .ToUri();

Url result:
http://mock/odata/ODataType?$filter=Color eq 'Blue'&$skip=1&$top=10

@alexandresanlim alexandresanlim changed the title add ToDicionary add ToDicionary() Sep 17, 2019
@alexandresanlim alexandresanlim changed the title add ToDicionary() add ToDictionary() Sep 17, 2019
@alexandresanlim alexandresanlim changed the title add ToDictionary() Add ToDictionary() and other things Sep 20, 2019
@ZEXSM ZEXSM added the enhancement New feature or request label Sep 21, 2019
@ZEXSM
Copy link
Owner

ZEXSM commented Sep 22, 2019

Hi, I looked at the changes you want to make. In general, I support, but I want to make changes, taking into account how I see the use of current changes and the use of the library in the future

I wanted to publish a new branch and do PR in https://github.com/alexandresanlim/OData.QueryBuilder but I did not have enough rights :)

@alexandresanlim
Copy link
Collaborator Author

Nice! I invited you as a contributor, I think that solves the issue of access.

@ZEXSM
Copy link
Owner

ZEXSM commented Sep 23, 2019

I created a PR. If it meets all your requirements, then I propose to merge :)

https://github.com/alexandresanlim/OData.QueryBuilder/pull/1

@alexandresanlim
Copy link
Collaborator Author

Merge confirmed.

@ZEXSM ZEXSM merged commit d7c7b70 into ZEXSM:master Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants