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

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

Open
brad302 opened this issue Feb 12, 2023 · 4 comments
Assignees

Comments

@brad302
Copy link

brad302 commented Feb 12, 2023

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

@StefH StefH changed the title "Type" keyword in property behaves badly in GroupBy "Type" keyword in property behaves incorrect in GroupBy Feb 14, 2023
@StefH StefH self-assigned this Feb 14, 2023
@brad302 brad302 changed the title "Type" keyword in property behaves incorrect in GroupBy "Type" keyword in property behaves incorrectly in GroupBy Feb 21, 2023
@StefH
Copy link
Collaborator

StefH commented Mar 3, 2023

Hello @brad302,

Thanks for the information, however can you please make a complete working dotnet-fiddle example project to demonstrate this issue?

@brad302
Copy link
Author

brad302 commented Mar 6, 2023

@StefH, hopefully this works for you ... https://dotnetfiddle.net/tOuoRd

I just realised the issue itself is buried in the ToDynamicList() method. From there, it's not doing what I expect. The Key that's being derived is skewed from the actual data when (as previously pointed out) the name of the property is Type.

Hopefully you can help.

Thanks

@brad302 brad302 changed the title "Type" keyword in property behaves incorrectly in GroupBy "Type" keyword in property behaves incorrectly in GroupBy (via ToDistinctList) Mar 6, 2023
@brad302
Copy link
Author

brad302 commented May 8, 2023

Any updates on this one by chance?

@StefH
Copy link
Collaborator

StefH commented Aug 9, 2023

@brad302
No updates yet. I need to debug this issue.

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

No branches or pull requests

2 participants