MyEntityCollection Casting Error

Posts   
 
    
Posts: 72
Joined: 11-Aug-2006
# Posted on: 04-Oct-2006 02:47:28   

Hi There

My apoligies if this is a stupid question!

I have 2 entities

order, country

order entity has 2 x relationships with country

delcountryid = country.ID billCountryID = country.ID

I am implementing 2 class code generation.

I use

MyOrderEntity order = new MyOrderEntity(orderID); using (DataAccessAdapter adapter = new DataAccessAdapter()) { PrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.OrderEntity); prefetch.Add(OrderEntity.PrefetchPathVwOrderSkuDetails); prefetch.Add(OrderEntity.PrefetchPathDelCountry); adapter.FetchEntity(order,prefetch); }

When I access order.DelCountry.CountryName - I get the following error.

Unable to cast object of type 'MCart.EntityClasses.CountryEntity' to type 'MCart.EntityClasses.MyCountryEntity'.

What is the best way to implement this scenario. I want all the extra functionality in the MY.. classes.

Thanks heaps. Marty

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 04-Oct-2006 08:28:33   

Are you using the Adapter model, or the SelfServicing 2 class model?

Please refer to the following threads, for questions guidlines: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7718

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 04-Oct-2006 10:29:52   

DelCountry should be of type MyDelCountry. Could you check that please? Also, as Walaa said, please follow the guidelines so we've as much info as possible. The 2-class templates for adapter were released for 1.0.2005.1 and v2.0 so we need additional info.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 72
Joined: 11-Aug-2006
# Posted on: 04-Oct-2006 19:54:50   

Otis wrote:

DelCountry should be of type MyDelCountry. Could you check that please? Also, as Walaa said, please follow the guidelines so we've as much info as possible. The 2-class templates for adapter were released for 1.0.2005.1 and v2.0 so we need additional info.

Yes version 2.0 ( Sep 8th 2006 ) , Adapter... sorry! Also DelCountry is type MyCountryEntity. Here is the code that fails in the generated code ( on the get ).

[Browsable(false)] public new virtual MyCountryEntity DelCountry { get { return (MyCountryEntity)base.DelCountry; } set { base.DelCountry = value; } }

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 05-Oct-2006 10:27:47   

You should use:


prefetch.Add(MyOrderEntity.PrefetchPathVwOrderSkuDetails);
prefetch.Add(MyOrderEntity.PrefetchPathDelCountry);

This will create different prefetch path nodes with different factories simple_smile

Frans Bouma | Lead developer LLBLGen Pro