AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

Multiple many-to-many relationships to same table #522

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create tables as specified on the attached ER-diagram
2. Generate the plinqo code
3. Look at the generated code for the Role, Organization and Group entities.

What is the expected output?
I would expect an EntitySet called Users in each of the entities

What do you see instead?
Role has an EntitySet called Users1
Organization has an EntitySet called Users2
Group has an EntitySet called Users3

What version of the product are you using?
v5.0.1.1966

Please provide any additional information below.
See attached ER-diagram (Multiple many-to-many.PNG)

Original issue reported on code.google.com by karb...@gmail.com on 2 Nov 2010 at 3:30

Attachments:

GoogleCodeExporter commented 9 years ago
Hello,

Could you please attach your schema sample so we can take a closer look into 
this issue.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 5 Nov 2010 at 3:22

GoogleCodeExporter commented 9 years ago
Hello,

Could you please attach your schema sample so we can take a closer look into 
this issue.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 17 Nov 2010 at 3:55

GoogleCodeExporter commented 9 years ago
Hi,

What do you mean by schema?:
.bak file with a backup of the database
.sql with create script
.dbml file
...?

Best regards,
René

Original comment by karb...@gmail.com on 18 Nov 2010 at 8:21

GoogleCodeExporter commented 9 years ago
Hi,

I still have this issue with the latest version of CodeSmith/PLINQO.
I have attached a simplified db that can be used to reproduce the issue.

Best regards,
René

Original comment by karb...@gmail.com on 4 Jan 2012 at 4:23

Attachments:

GoogleCodeExporter commented 9 years ago
I think the error is in the template 'Entity.Generated.cst', line 981 to 988:
        string original = manyMany.PropertyName;
        int count = 1;

        while(Type.IsUniqueMember(manyMany.PropertyName) == false
            || manyToManyNames.Contains(manyMany.PropertyName))
        {
            manyMany.PropertyName = original + (count++).ToString();
        }

It is correct that the PropertyName must be unique, but it doesn't have to be 
unique across different entities.

Original comment by karb...@gmail.com on 4 Jan 2012 at 4:47

GoogleCodeExporter commented 9 years ago
Hello,

Thanks, I'll take a look and let you know what I find.

Original comment by bniemyjski on 11 Jan 2012 at 4:46

GoogleCodeExporter commented 9 years ago
Hello,

I was not able to reproduce this issue with Generator 6.0.1 and the latest 
nightly build 
(http://community.codesmithtools.com/nightly/PLINQO/plinqo-r2415.zip). Could 
you please try reproducing using the build above with generator 6.0.

When I look at the various entities. I see the right EntitySet's and names.

Original comment by bniemyjski on 11 Jan 2012 at 10:27

GoogleCodeExporter commented 9 years ago
Hi,

I tried to do as you suggested (newest build), but without luck.

Please take a look at the following code:
using (var context = new ManyToManyDataContext())
{
    Role role = context.Role.First();
    IEnumerable<UserRole> userRoleList = role.UserRoleList;
    IEnumerable<User> users = role.Users;

    Team team = context.Team.First();
    IEnumerable<TeamMember> teamMemberList = team.TeamMemberList;
    IEnumerable<User> teamMembers = team.Users1; //I expected
team.TeamMemberList, team.TeamMembers or at least team.Users
}

Why does the property with users on the team end up with the propertyname
Users1?

Original comment by karb...@gmail.com on 12 Jan 2012 at 7:28

GoogleCodeExporter commented 9 years ago
Hi,

Di you have time to look at my issue?

Original comment by karb...@gmail.com on 20 Jan 2012 at 8:27

GoogleCodeExporter commented 9 years ago
Hi,

Any news regarding this problem?

Original comment by karb...@gmail.com on 31 Jan 2012 at 7:04

GoogleCodeExporter commented 9 years ago
Hello,

When I generate, I get the following: 

                Role role = context.Role.First();
                IEnumerable<UserRole> userRoleList = role.UserRoleList;
                IEnumerable<User> users = role.UserList;

                Team team = context.Team.First();
                IEnumerable<TeamMember> teamMemberList = team.TeamMemberList;
                IEnumerable<User> teamMembers = team.UserList1; //I expected
                var x = team.TeamMemberList;

You may want to delete your dbml file and regen, as the names might be 
preserved.

Original comment by bniemyjski on 1 Feb 2012 at 1:59

GoogleCodeExporter commented 9 years ago
Did deleting the dbml file resolve this issue?

Original comment by bniemyjski on 23 Aug 2012 at 8:10