PrefetchPath property not available in entity class

Posts   
 
    
Prafull
User
Posts: 24
Joined: 17-Jun-2008
# Posted on: 27-Jun-2008 00:05:24   

Hi,

I am using LLBLGen 2.6 demo version.

I want to load the data for dependent entities. For that i am trying to use "PrefetchPath..".

Currently i am not getting property on my entity class to add in to PrefetchPath2 object.

Could you please let me know what do i need to get the properties?

I my sql server 2005 database i have PK, FK relationship. By default Codegenerator is not generating relationship based on the table schema.

Regards, Pafull

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 27-Jun-2008 10:16:19   

By default Codegenerator is not generating relationship based on the table schema.

What do you mean?

Prafull
User
Posts: 24
Joined: 17-Jun-2008
# Posted on: 27-Jun-2008 15:20:57   

Walaa wrote:

By default Codegenerator is not generating relationship based on the table schema.

What do you mean?

What i understood from the documentation that if PK is define in Database, LLBLGen will generate the relationship by default.

Is my understanding correct?

If yes then when i generated the code i did not find any files/code for that.

Second point i am also not getting prefecthpathXXX proprety in entity.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 27-Jun-2008 15:39:46   

What i understood from the documentation that if PK is define in Database, LLBLGen will generate the relationship by default.

I have to correct you on this. LLBLGen Pro recognizes database relations if they there is a FK pointing to the PK of another entity/table.

So the question is: do you have referential relations (as described above) implemented in your database?

Prafull
User
Posts: 24
Joined: 17-Jun-2008
# Posted on: 27-Jun-2008 15:42:18   

Walaa wrote:

What i understood from the documentation that if PK is define in Database, LLBLGen will generate the relationship by default.

I have to correct you on this. LLBLGen Pro recognizes database relations if they there is a FK pointing to the PK of another entity/table.

So the question is: do you have referential relations (as described above) implemented in your database?

Yes we have implemented referential relations in our database.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 27-Jun-2008 15:46:11   

If these are many to many relations, is the HideManyToManyRelationsOnCreation project property set to true?

Would you please examine the LLBLGen Pro designer, and check if the specified relations are set as hidden or not?

Prafull
User
Posts: 24
Joined: 17-Jun-2008
# Posted on: 27-Jun-2008 15:58:16   

Walaa wrote:

If these are many to many relations, is the HideManyToManyRelationsOnCreation project property set to true?

Would you please examine the LLBLGen Pro designer, and check if the specified relations are set as hidden or not?

Earlier when i generated the code this property was set to true. I chnaged the property value to false and generated the code once again but still i did not get

XXXEntity.PrefetchPathYYY

Where XXX and YYY entity has PK-FK relation ship.

Do i need to some other setting in designer?

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 27-Jun-2008 16:03:01   

Please check if the relation is set as hidden at any side of it. (Check the relations tab of each entity; in the designer)

Prafull
User
Posts: 24
Joined: 17-Jun-2008
# Posted on: 27-Jun-2008 16:25:30   

Walaa wrote:

Please check if the relation is set as hidden at any side of it. (Check the relations tab of each entity; in the designer)

There is no relation attribute generated for any of the entities when i refereshed the catalog or even i created it first time.

BUT when i just now tried creating one relationship manually, and regenerated the code. Now i got the "PrefetchPath".

So my question is, how do i get the relationship by default (when designer is refreshing or first time scanning the database schema)?

I am pretty much sure LLBLGen Designer can do this but i am missing some flag to be set.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39870
Joined: 17-Aug-2003
# Posted on: 27-Jun-2008 17:11:53   

You need Foreign key constraints in your tables (from FK side to PK side), and then the relations are added automatically. simple_smile However, if the FK constraints aren't defined correctly, they're not picked up. Please check the Application output window after the refresh to see if it ignored FK constraints. Also, if you defined hte FK constraint on the PK table, it won't be picked up as that's backwards, you've to define them on the FK table. (e.g. Customer & Order, the FK has to be defined on Order, pointing to Customer)

Also, please don't quote your own text in posts, that's not necessary simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Prafull
User
Posts: 24
Joined: 17-Jun-2008
# Posted on: 27-Jun-2008 18:38:59   

Otis wrote:

You need Foreign key constraints in your tables (from FK side to PK side), and then the relations are added automatically. simple_smile However, if the FK constraints aren't defined correctly, they're not picked up. Please check the Application output window after the refresh to see if it ignored FK constraints. Also, if you defined hte FK constraint on the PK table, it won't be picked up as that's backwards, you've to define them on the FK table. (e.g. Customer & Order, the FK has to be defined on Order, pointing to Customer)

Also, please don't quote your own text in posts, that's not necessary simple_smile

FK constraint has been defined correctly. When I see the table relationship for tables using SQL Server 2005 server management studio, both tables have the constraint. I can say its defined both ways. (e.g. Customer & Order, the FK has been defined on Order, pointing to Customer and in Customer table its mentioned that customer id is a primary key on order table)

In Application output window i did not find that designer has ignored any FK constraints.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39870
Joined: 17-Aug-2003
# Posted on: 27-Jun-2008 19:25:42   

Please post a DDL SQL snippet of two tables with FK constraint and PK constraint. We can't reproduce what you're seeing here with our models.

Frans Bouma | Lead developer LLBLGen Pro
Prafull
User
Posts: 24
Joined: 17-Jun-2008
# Posted on: 27-Jun-2008 21:50:22   

Otis wrote:

Please post a DDL SQL snippet of two tables with FK constraint and PK constraint. We can't reproduce what you're seeing here with our models.

I have attached the SQL for 2 tables. Thanks.

Attachments
Filename File size Added on Approval
TableSchema.zip 2,602 27-Jun-2008 21:51.30 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Jun-2008 05:22:19   

Hi Prafull,

I can't reproduce your issue disappointed Here is what I did:

  1. Create a SchemaTest DB.
  2. Create the schemas Lookup and Org.
  3. Modify a little bit your DDL (delete foreign keys of nonexistent tables)
  4. Run your scripts.
  5. Create New Project at LLBLGenPro v2.6
  6. Add the two entities. At this point, LLBLGenPro added successfully the relation between Organization and DesignCenter.
  7. Generate code.

Doing a simple test with the generated code, I am able to write something like this:

OrganizationEntity org = new OrganizationEntity();
IPrefetchPath2 path = new PrefetchPath2((int)EntityType.OrganizationEntity);
path.Add(OrganizationEntity.PrefetchPathDesignCenter);

DesignCenterEntity dc = new DesignCenterEntity();
IPrefetchPath2 path2 = new PrefetchPath2((int)EntityType.DesignCenterEntity);
path2.Add(DesignCenterEntity.PrefetchPathOrganization);

So, I can't reproduce it disappointed If you create a new project and do my steps listed above, do you still have the problem? If you create a new project with just that two entities, do you still have the problem?

David Elizondo | LLBLGen Support Team
Prafull
User
Posts: 24
Joined: 17-Jun-2008
# Posted on: 30-Jun-2008 17:40:35   

daelmo wrote:

Hi Prafull,

I can't reproduce your issue disappointed Here is what I did:

  1. Create a SchemaTest DB.
  2. Create the schemas Lookup and Org.
  3. Modify a little bit your DDL (delete foreign keys of nonexistent tables)
  4. Run your scripts.
  5. Create New Project at LLBLGenPro v2.6
  6. Add the two entities. At this point, LLBLGenPro added successfully the relation between Organization and DesignCenter.
  7. Generate code.

Doing a simple test with the generated code, I am able to write something like this:

OrganizationEntity org = new OrganizationEntity();
IPrefetchPath2 path = new PrefetchPath2((int)EntityType.OrganizationEntity);
path.Add(OrganizationEntity.PrefetchPathDesignCenter);

DesignCenterEntity dc = new DesignCenterEntity();
IPrefetchPath2 path2 = new PrefetchPath2((int)EntityType.DesignCenterEntity);
path2.Add(DesignCenterEntity.PrefetchPathOrganization);

So, I can't reproduce it disappointed If you create a new project and do my steps listed above, do you still have the problem? If you create a new project with just that two entities, do you still have the problem?

Hi,

I created new project and selected all the tables available in my database, now when i add entity i am getting relations. Great simple_smile I guess some strange setting/thing with my database.

Thanks for your support and time.