Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> Related entity not set in derived collection
 

Pages: 1
LLBLGen Pro Runtime Framework
Related entity not set in derived collection
Page:1/1 

  Print all messages in this thread  
Poster Message
raist
User



Location:
Madrid, Spain
Joined on:
19-Apr-2010 23:57:10
Posted:
114 posts
# Posted on: 16-Aug-2012 17:27:32.  
Problem description
I try to get a collection with a prefetch path, but the related entity is only set in some of the collection's elements.
It only happens when Target per entity hierarchy is used and a field of each derived entity (ex. int) is mapped to the same field in the database.
Maybe is this mapping not allowed?

Llblgen Pro v.3.5 August 8th, 2012

Example:
- Two entities DocumentEntity & FolderEntity
- Two derived entities DocEventEntity & FolderEventEntity (basetype: BaseEventEntity, abstract).
Target per entity hierarchy.

- DocEventEntity has a field IdDocument, mapped to the IdEntity field in the database. It is a FK to a DocumentEntity (navigator: Document)
- FolderEventEntity has a field IdFolder, mapped to the same IdEntity field in the database. It is a FK to a FolderEntity (navigator: Folder)
- BaseEventEntity has no field mapped to IdEntity

Now, I try...

Code:
PrefetchPath prefetchPath = new PrefetchPath(EntityType.FolderEventEntity);
prefetchPath.Add(FolderEventEntity.PrefetchPathFolder);
FolderEventCollection collection = new FolderEventCollection();
collection.GetMulti(null, prefetchPath);
FolderEventEntity ev = collection[0];
string folderName = ev.Folder.Nombre; // Folder is null!!!


... but the .Folder is only set in the last event with that folder (ex. event1, event2 & event3 point to folder1, then only event3.Folder is set)

Thanks in advance,

Jose
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 16-Aug-2012 20:20:03.  
Quote:
- DocEventEntity has a field IdDocument, mapped to the IdEntity field in the database. It is a FK to a DocumentEntity (navigator: Document)
- FolderEventEntity has a field IdFolder, mapped to the same IdEntity field in the database. It is a FK to a FolderEntity (navigator: Folder)

In which table does the IdEntity exist?
How come same field has 2 Fks, pointing to 2 different tables?


  Top
raist
User



Location:
Madrid, Spain
Joined on:
19-Apr-2010 23:57:10
Posted:
114 posts
# Posted on: 17-Aug-2012 09:16:42.  
Code:
CREATE TABLE [WF].[BaseEvent]
(
    [IdEvento] [int] IDENTITY (1,1) NOT NULL, -- PK field
    [AsociadoA] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -- Discriminator field (DOC/FOL)
    [IdEntity] [int] NOT NULL -- FK field (points to document.IdDocument or folder.IdFolder)
) ON [PRIMARY]
GO

As it is a 'Target per entity hierarchy' it seems allowed. Confused
Would the VS 2010 & Llblgen projects help?
  Top
raist
User



Location:
Madrid, Spain
Joined on:
19-Apr-2010 23:57:10
Posted:
114 posts
# Posted on: 17-Aug-2012 10:17:31.  
Solved!
Of course it is allowed to map two fields in two different derived entities to the same database column.
The problem was with the defined cardinality (1:1 when it should be m:1).
Of course with 1:1, it does not expect related entities to be repeated, therefore it only set the last one (I suppose because of performance).
Once changed to m:1 it works great (as always Laugh)

Thanks


  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.