You are not logged in.
Hi,
I know this question is not about mORMot Framework but on this forum some programmer are expert and maybe can help me.
I have this structure in C#
public class User
{
...
public ICollection<UserGroup> Groups { get; set; }
...
}
public class UserGroup
{
...
public User User { get; set; }
...
}
As you can see, User is in UserGroup and UserGroup is in User
In C# you can this
But I need to use same structure in Delphi 6 but I have circular reference between two unit (User and UserGroup)
Someone have a suggestion because I need to serialize and deserialize JSON from C# to Delphi and vice-versa
Thank you
Offline
Create a single unit with both classes, then define your class as forward.
type
TUserGroup = class; // forward declaration
TUser = class
...
here you can use TUserGroup
TUserGroup = class // real TUserGroup definition
...
In C# and Java, you are used to define one source code file per class.
In Delphi, it is not wanted, nor possible, since the on-pass compiler avoid circular references, and therefore the solution is to define all circular references classes in a single unit.
Offline