LINQ Reporting GroupBy Issue

Hello

I am trying to implement the group by with the same scenario.
I have a problem implementing the IEquatable. With the following codes the group by does not work.

image.png (20.1 KB)
image.png (12.4 KB)

And test template :

<<foreach [group in Project.TestReportList.GroupBy(c=>c.TestSettings)]>>

<<[Key.Name]>>

<<foreach [in group]>>

<<[Name]>>

<</foreach>>

<</foreach>>

The report out is :

0

Test0

0

Test1

1

Test2

1

Test3

If i use this code, the group by is ok, but it requires us a lot more job on the model
image.png (27.6 KB)
see my console application as an exampleConsoleAppAspose.zip (34.6 KB)

@miniseb31,

We have logged your problem in our issue tracking system. Your ticket number is WORDSNET-17942. We will further look into the details of this problem and will keep you updated on the status of the linked issue.

Hello
Thanks for your reply,

is there a way to add a IComparer in the group by function so we can control the unicity of objects ?

sebastien

@miniseb31,

We have logged your comment in our issue tracking system and will keep you posted on any further updates.

@miniseb31,

Regarding WORDSNET-17942, we have completed the work on your issue and concluded to close this issue as ‘Not a Bug’. Please see the following analysis details:

The unexpected behavior is caused by your code that does not follow Microsoft recommendations on implementing IEquatable:

The code does not override Equals(Object) for TestSettings which is used by LINQ Reporting Engine. However, everything works as expected if TestSettings is modified according to the Microsoft recommendation (i.e. Equals(Object) is overridden) as follows:

public class TestSettings : IEquatable<TestSettings>
{
    public int Id { get; set; }
 
    public string Name { get; set; }
 
    public bool Equals(TestSettings other)
    {
        return ((other != null) && (other.Id == this.Id));
    }
 
    public override bool Equals(object obj)
    {
        return Equals(obj as TestSettings);
    }
 
    public override int GetHashCode()
    {
        return this.Id.GetHashCode();
    }
}

Hope, this helps.