EntityCollection with prefetchpath

Posts   
 
    
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 06-May-2009 05:30:31   

Hi i have a staff entity which has one to many type relationship to EmergencyContact entity. And EmergencyContact has a field called RelationshipTypeID which is a foreign key for RelationShip entity's primary key.

I am trying to get the EmergencyContact collection with RelationshipDescription of a given staff.

public static StaffEmergencyContactCollection GetEmergencyContactListForStaff(int staffId) { StaffEntity staff = new StaffEntity(staffId);

        StaffEmergencyContactCollection toReturn = staff.StaffEmergencyContact;

        return toReturn;
    }

how can i get RelationshipDescription here. If i was to return an entity i would define a prefetchpath but i dont know how it works with entity collections. Any ideas? thanks

-shane

Using llblgen 2.6,self servicing, C#. .net 3.5, VS 2008, MS SQL 2008 Express

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 06-May-2009 06:09:27   

This should help. It is pretty straight forward. Let me know if this makes sense.

e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 06-May-2009 07:33:19   

ok i think i asked the question wrong. i want the EmergencyContact entity collection have the RelationshipDescription when fetched. Right now it has RelationshipID. i dont want to create a typled list or view for that. i thought that d be possible with prefecth paths but i was wrong. how can i have the RelationshipDescription in the EmergencyContact collection? thanks

-shane

Seth wrote:

This should help. It is pretty straight forward. Let me know if this makes sense.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 06-May-2009 08:31:55   

You use Fields mapped on related fields

Please read it carefully.

e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 06-May-2009 18:15:24   

thank you. i read it carefully simple_smile so i believe i have to create a new Entity (like EmergencyContactWithRelationship) if i want to extend its field collection with the related entities since i want to keep my base entity as it is.

thank you for the pointer -shane

Walaa wrote:

You use Fields mapped on related fields

Please read it carefully.

e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 06-May-2009 18:45:41   

ok i have a problem here. adding fields from a related table worked fine but i wanted to keep my base entity and created a new one which is named as StaffEmergencyContact_ by default. Since i made changes to my StaffEmergencyContact already i decided the make the second one i added my base entity and rename the first one. So i renamed the one i added fields from a related entity to EmergencyContactWithRelationship. And renamed the second one i created which points to the base database table to EmergencyContact.

So now EmergencyContact is mapped on my database table and EmergencyContactWithRelationship has extra fields from the related Relationship table. Saved the project, regenerated the code but the names for the old entity or the new one didnt change in generated project. My ClenaUpVSNetProject is set to true. staff "dot" gives me StaffEmergencyContact and StaffEmergencyContact_. isnt it supposed to give EmergencyContact and EmergencyContactWithRelationship?

what do you think is the problem? -shane

Walaa wrote:

You use Fields mapped on related fields

Please read it carefully.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-May-2009 06:02:30   

Please double check the name of the entities at LLBLGen Designer. Could you attach the lgp?

David Elizondo | LLBLGen Support Team
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 07-May-2009 06:36:02   

i did. had to delete the old folders and re-generate the project. i dont know why it wouldnt update over the old ones. i ll demo a sample project and see if it happens again. thanks -shane

daelmo wrote:

Please double check the name of the entities at LLBLGen Designer. Could you attach the lgp?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 07-May-2009 09:56:34   

My ClenaUpVSNetProject is set to true.

Is this set in the LLBLGen Pro Designer Preferences or in the Project Properties?

e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 07-May-2009 16:02:52   

project properties

Walaa wrote:

My ClenaUpVSNetProject is set to true.

Is this set in the LLBLGen Pro Designer Preferences or in the Project Properties?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 07-May-2009 18:22:10   

If you delete the project folder completely and regenerate from scratch, does it produce the desired results ?

There are various reasons why the clean up does not work - the most common is that the project and class files are read-only due to being under source control. Could this be the case ?

Thanks

Matt

e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 07-May-2009 19:27:23   

yes they are under source control but changing field names or table names, refreshing the catalog and generating the project never gave me a problem before. my syncmappedelements.. and syncmappedfields... is set to true.

and yes it produced the desired result.

thanks -shane

MTrinder wrote:

If you delete the project folder completely and regenerate from scratch, does it produce the desired results ?

There are various reasons why the clean up does not work - the most common is that the project and class files are read-only due to being under source control. Could this be the case ?

Thanks

Matt