Skip to content

group by on date throws exceptions - #2302

Merged
ElizabethOkerio merged 2 commits into
OData:masterfrom
ElizabethOkerio:fix/2296_group_by_datetime_exceptions
Oct 8, 2020
Merged

ElizabethOkerio merged 2 commits into
OData:masterfrom
ElizabethOkerio:fix/2296_group_by_datetime_exceptions

Conversation

@ElizabethOkerio

@ElizabethOkerio ElizabethOkerio commented Sep 29, 2020 •

Copy link
Copy Markdown
Contributor

Issues

This pull request fixes issue #2296 , #912, #1945, #918

Description

OData doesn't include DateTime as a primitive type. If a user defines a model as

public class Customer
{
    public int Id { get; set; }
    public DateTime Birthday { get; set; }
}

then tries to do a groupBy using the Birthday Column, an exception is thrown.

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Build and test with one-click build and test script passed

Additional work necessary

If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.

@ElizabethOkerio
ElizabethOkerio marked this pull request as ready for review October 5, 2020 13:40
@ElizabethOkerio
ElizabethOkerio force-pushed the fix/2296_group_by_datetime_exceptions branch 2 times, most recently from 5722272 to fbd6a58 Compare October 6, 2020 12:28
@ElizabethOkerio
ElizabethOkerio force-pushed the fix/2296_group_by_datetime_exceptions branch from fbd6a58 to 35b8e28 Compare October 6, 2020 13:31

@gathogojr gathogojr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


HttpResponseMessage response = await Client.GetAsync(requestUri);

Assert.Equal(HttpStatusCode.OK, response.StatusCode);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert.Equal(HttpStatusCode.OK, response.StatusCode); [](start = 12, length = 53)

at least verify the repsonse content?

property = new ODataProperty
{
Name = prop.Key,
Value = ODataPrimitiveSerializer.ConvertPrimitiveValue(prop.Value, edmProperty.Type.AsPrimitive())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edmProperty.Type.AsPrimitive() [](start = 103, length = 30)

It is always a primitives' type?

foreach (var prop in dynamicObject.Values)
{
IEdmProperty edmProperty = entityType?.Properties()
.FirstOrDefault(p => p.Name.Equals(prop.Key));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p.Name.Equals(prop.Key) [](start = 49, length = 23)

Why simple compare the property name here?

  1. does it case sensitive?
  2. property alias?

xuzhg pushed a commit that referenced this pull request May 29, 2026
* group by on date throws exceptions

* fix based on review comments
pull Bot pushed a commit to ehtick/WebApi that referenced this pull request May 29, 2026
* group by on date throws exceptions

* fix based on review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants