Skip to content

"Type" keyword in property behaves incorrectly in GroupBy (via ToDistinctList) #673

@brad302

Description

@brad302

I believe I’ve found an issue with the System.Linq.Dynamics.Core library and the GroupBy method.

It may very well be happening elsewhere but I’ll let you work that out.

With this JSON …

[
  {
    "Name": "Mr. Test Smith",
    "Type": "ACCOUNTSPAYABLE",
    "Something": {
      "Field1": "Test1",
      "Field2": "Test2"
    }
  },
  {
    "Name": "Mr. Test Smith",
    "Type": "DISPATCH",
    "Something": {
      "Field1": "Test1",
      "Field2": "Test2"
    }
  },
  {
    "Name": "Different Name",
    "Type": "ACCOUNTSPAYABLE",
    "Something": {
      "Field1": "Test3",
      "Field2": "Test4"
    }
  }
]

… when I execute GroupBy with the following keySelectornew (Type, Something.Field1) … the resulting data misrepresents the Type field values.

I then create an array of key/values with the grouping results and this is what comes out. You can see that property Type simply comes back as a value of 1 and not the values within the fields themselves.

This is the resulting response from my framework.

[
    {
        "Key": {
            "Type": 1,
            "Field1": "Test1"
        },
        "Values": [
            {
                "Name": "Mr. Test Smith",
                "Type": "ACCOUNTSPAYABLE",
                "Something": {
                    "Field1": "Test1",
                    "Field2": "Test2"
                }
            },
            {
                "Name": "Mr. Test Smith",
                "Type": "DISPATCH",
                "Something": {
                    "Field1": "Test1",
                    "Field2": "Test2"
                }
            }
        ]
    },
    {
        "Key": {
            "Type": 1,
            "Field1": "Test3"
        },
        "Values": [
            {
                "Name": "Different Name",
                "Type": "ACCOUNTSPAYABLE",
                "Something": {
                    "Field1": "Test3",
                    "Field2": "Test4"
                }
            }
        ]
    }
]

If I change the property name from “Type” to something else, it works fine.

Keen to get your thoughts on this.

Thanks

Brad

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions