v3.1 - problem with duplicate method name in generated code

Posts   
 
    
hotchill avatar
hotchill
User
Posts: 180
Joined: 22-Jan-2007
# Posted on: 12-Jul-2011 03:46:53   

Hi.

I have a SPBase entity inherited by a SPTask entity. A SPAuditEntry entity has FK to SPBase. I added an additional relationship on this FK to SPTask so that SPBase can have a field called TargetTask of type SPTask.

If I go to v2.6 designer and check Relations of SPTask, I don't see the relation from SPTask to SPAuditEntry, i.e. the model has a one way relationship from SPAuditEntry to SPTask. The v3.1 designer however has this relationship as two way and I am not able to change that without also removing it as SPAuditEntry to SPTask relationship. I tried not entering a navigator name for SPAuditEntry collection of SPTask, but that did not help. It was not listed under navigators anymore though.

Any ideas? Below is the snipped generated code which is not compiling.

Thanks, Tore.

/// <summary>Returns a new IEntityRelation object, between SPTaskEntity and SPAuditEntryEntity over the 1:n relation they have, using the relation between the fields:
        /// SPTask.SPBaseId - SPAuditEntry.SPEntityId
        /// </summary>
        public override IEntityRelation SPAuditEntryEntityUsingSPEntityId
        {
            get
            {
                IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "AuditLog" , true);
                relation.AddEntityFieldPair(SPTaskFields.SPBaseId, SPAuditEntryFields.SPEntityId);
                relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SPTaskEntity", true);
                relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SPAuditEntryEntity", false);
                return relation;
            }
        }

        /// <summary>Returns a new IEntityRelation object, between SPTaskEntity and SPAuditEntryEntity over the 1:n relation they have, using the relation between the fields:
        /// SPTask.SPBaseId - SPAuditEntry.SPEntityId
        /// </summary>
        public virtual IEntityRelation SPAuditEntryEntityUsingSPEntityId
        {
            get
            {
                IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "" , true);
                relation.AddEntityFieldPair(SPTaskFields.SPBaseId, SPAuditEntryFields.SPEntityId);
                relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SPTaskEntity", true);
                relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SPAuditEntryEntity", false);
                return relation;
            }
        }
hotchill avatar
hotchill
User
Posts: 180
Joined: 22-Jan-2007
# Posted on: 12-Jul-2011 04:06:25   

Please read this too: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=20065&StartAtMessage=0&#113242

When going from scratch with the RelationshipsFollowDBForeignKeyConstraints flag lowered, I still get this issue.


type 'NetConnect.Project.ControlPanel.Data.RelationClasses.StaticSPTaskRelations' already contains a definition for '[b]SPAuditEntryEntityUsingSPEntityIdStatic'[/b]    G:\ByteTecSourceCode\NetConnect\Project\ControlPanel\trunk\NetConnect.Project.ControlPanel.Data\DatabaseGeneric\RelationClasses\SPTaskRelations.cs  269 44  NetConnect.Project.ControlPanel.Data

Error   88  The type 'NetConnect.Project.ControlPanel.Data.RelationClasses.SPTaskRelations' already contains a definition for [b]'SPAuditEntryEntityUsingSPEntityId'[/b]    G:\ByteTecSourceCode\NetConnect\Project\ControlPanel\trunk\NetConnect.Project.ControlPanel.Data\DatabaseGeneric\RelationClasses\SPTaskRelations.cs  59  34  NetConnect.Project.ControlPanel.Data
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 12-Jul-2011 12:20:25   

Is this a TragetPerEntity, or a TargetPerHierarchy, as I'm trying to reproduce it? Or could you please attach a simple repro project file.

hotchill avatar
hotchill
User
Posts: 180
Joined: 22-Jan-2007
# Posted on: 12-Jul-2011 15:03:36   

It is target per entity. I will reproduce and attach an example file for you.

Update: Attachment file added. It is pending approval.

.\DatabaseGeneric\RelationClasses\SPTaskRelations.cs has the duplication issue.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 12-Jul-2011 22:21:53   

Hi

Thanks for the repro solution - I've reproduced the issue as you've described. We'll investigate and get back to you.

Thanks

Matt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39612
Joined: 17-Aug-2003
# Posted on: 13-Jul-2011 11:54:30   

Isn't SPTask 1:n SPAuditEntry a duplicate of SPBase 1n SPAuditEntry? The reason I ask is that both relationships are between the same fields (pk and fk). Setting the FK field in SPAuditEntry will automatically influence the other relationship, as they're effectively equal.

I'd remove the relationship between SPTask and SPAuditEntry and add a property TargetTask to a partial class of SPAuditEntry which simply does:

public SPTaskEntity TargetTask { get { return this.TargetEntity as SPTaskEntity;} set { this.TargetEntity = value;} }

as it is actually the same thing as SPBase - SPAuditEntry

Frans Bouma | Lead developer LLBLGen Pro
hotchill avatar
hotchill
User
Posts: 180
Joined: 22-Jan-2007
# Posted on: 14-Jul-2011 01:57:34   

Yeah, it is a duplicate as you state. I got some other stuff that needs fixing first and then I will test this, though thinking about it, I believe it will fail.

If the TargetEntity is not SPTaskEntity and I pass ExcludeFieldList in the prefetch to not fetch all task fields, it may fail.

In same scenario, if I need to fetch a related entity of SPTaskEntity, say assignee user, the sub prefetch path will fail I presume.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 14-Jul-2011 09:08:53   

Waiting for your testing outcome.

But in the mean time, does SPAuditEntry have any realtion with descendants of SPBase other than SPTask? If the answer is no, then I guess you don't need the relation with SPBase.

hotchill avatar
hotchill
User
Posts: 180
Joined: 22-Jan-2007
# Posted on: 14-Jul-2011 12:55:07   

The answer is yes. SPAuditEntry can have relation to other SPBase descendants than task, such as a document and event.

I have a similary scenario with a SPEntityUserRoleAssignment table. This table has a relation to SPBase.


// SPBase may not be of type SPWeb. I put it like this after removing the additional relation from SPEntityUserRoleAssignment to SPWeb
prefetchPath.Add(SPEntityUserRoleAssignmentEntity.PrefetchPathSPBase) .SubPath.Add(SPWebEntity.PrefetchPathWorkspace).SubPath.Add(WorkspaceEntity.PrefetchPathCustomer);
// it used to be like this
prefetchPath.Add(SPEntityUserRoleAssignmentEntity.PrefetchPathSPWeb) .SubPath.Add(SPWebEntity.PrefetchPathWorkspace).SubPath.Add(WorkspaceEntity.PrefetchPathCustomer);             

The topmost looks wrong to me and I'd prefer not have it like this because I feel like it will come back and bite me in the ass, but it seems to work. I need to test when the SPBase is not of type SPWeb.

hotchill avatar
hotchill
User
Posts: 180
Joined: 22-Jan-2007
# Posted on: 14-Jul-2011 15:25:51   

It works. Do you think I should move forward with this solution then?

Thanks, Tore.

Update: For relations I had to add the link explicitly:

filter.Relations.Add(SPBaseEntity.Relations.GetSubTypeRelation(EntityType.SPWebEntity.ToString()));
MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 14-Jul-2011 20:30:16   

Yes - looks like this is the way to go.

Matt