Prefetch Path and FetchPolymorphic

Posts   
 
    
Posts: 1263
Joined: 10-Mar-2006
# Posted on: 20-Dec-2008 17:11:27   

I am using FetchPolymorphic to retrieve an Entity in a multitable hierarchy. I need to use a prefetch path with this....there does not seem to be an overload on this.

I am trying to prefetch from the 'main' table of the inheritance, not the 'joined' tables of course.

Please advise.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Dec-2008 06:04:59   

Have you seen Polymorphic PrefetchPaths? Could you please elaborate more on your scenario?

David Elizondo | LLBLGen Support Team
Posts: 1263
Joined: 10-Mar-2006
# Posted on: 21-Dec-2008 18:35:06   

Well, that is simply a link to the help file which talks about polymorphic prefetch paths. They are really no different in use that regular prefetch path.

Here is my problem:

Given the Pkey for an entity NOT in a hierarchy;

  • Create PrefetchPath
  • use "new MyRegularEntity(pkey, prefetchpath);

Given that same siutation for an entity IN a hierarchy; - Create PrefetchPath - attempt to use use someentity.FetchPolymorphic(.....)

Guess what - there is no signature of FetchPolymorphic that uses a prefetch path!

(Obviously, I am trying to fetch a single entity here, not a collection of entities)

Advice?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 21-Dec-2008 18:54:57   

that's indeed an oversight. Unfortunately, adding it requires a change to DaoBase and a change to a template, which is a breaking change (as some people might not update them both in sync as we've learned the hard way in the past), so I can't add this for you today to the templates.

A workaround exists, which is fetching the entity through a collection using a PK filter. Not ideal, but should give you the data required.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 1263
Joined: 10-Mar-2006
# Posted on: 21-Dec-2008 19:52:32   

Wow...that is tough to have to classify as anything that changes a template and base at the same time to be a "breaking change"......need to have people update entire groups of related changes or none at all...

Anyway, that sucks - but doable....I assume you will fix/add this at some next release point?

While I am at it - any reason why this is not a static method to start with?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 21-Dec-2008 21:01:58   

WayneBrantley wrote:

Wow...that is tough to have to classify as anything that changes a template and base at the same time to be a "breaking change"......need to have people update entire groups of related changes or none at all...

We didn't classify it as breaking changes when a change in the templates required a specific build of the changed runtime libs but this was a mistake as we had customers run into problems where templates were updated and runtimes were not and 'missingmethodexception' crap was popping up. This thus made us change policy and things which require changes in more than 1 element (e.g. designer AND runtime, runtime AND designer etc.) won't be done but are postponed till the next version. C'est la vie.

Anyway, that sucks - but doable....I assume you will fix/add this at some next release point?

yes, it's scheduled for v3.

While I am at it - any reason why this is not a static method to start with?

FetchPolymorphic is a static method, so I don't know what you're referring to?

Frans Bouma | Lead developer LLBLGen Pro
Posts: 1263
Joined: 10-Mar-2006
# Posted on: 21-Dec-2008 21:17:26   

We didn't classify it as breaking changes

Yeah, I am not questioning what you do there.....you guys do a GOOD job of releasing code that works - mostly I would guess because of your extensive unit testing. The worst thing is you have very, very few small 'point' releases....consider 2.5 to 2.6 - that was not a small release - had significant add-ons (as you know). However for this fix, it will be 6-9 months before it can make it in, because there will not be a 2.61 or 2.7...instead it will be a MAJOR release of 3.0 which will take a while.....anyway, no big deal on this item for sure....

FetchPolymorphic is a static method, so I don't know what you're referring to?

Uh...good! smile

I briefly got cross thoughts from UC methods which are made as members - so I have to instantiate then call....

I thought I would quickly make an extension method that did fixed this problem by wrapping the call in a collection, etc - however, I remembered that could not be done.

<CompilerFeatureRequest> Microsoft Extension methods - I wish they would come up with a way in which I could make a static extension of a class, instead of an instance extension. This is the 2nd time I have wanted to do something like this. </CompilerFeatureRequest>

Anyway, I will probably just add a static method in the partial class of this currently one scenario I need it in....suprisingly this just has not come up before....

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 22-Dec-2008 10:40:33   

WayneBrantley wrote:

We didn't classify it as breaking changes

Yeah, I am not questioning what you do there.....you guys do a GOOD job of releasing code that works - mostly I would guess because of your extensive unit testing. The worst thing is you have very, very few small 'point' releases....consider 2.5 to 2.6 - that was not a small release - had significant add-ons (as you know). However for this fix, it will be 6-9 months before it can make it in, because there will not be a 2.61 or 2.7...instead it will be a MAJOR release of 3.0 which will take a while.....anyway, no big deal on this item for sure....

Yes, the versioning is a bit off... 2.1 became v2.5, and 2.6 didn't take 2 months but 9 months (due to the linq provider which took over 8 months).

If a breaking bugfix is required, we'll release a point release, though for feature changes, we postpone them to the next version, as we'll otherwise end up breaking out of v3 development and instead revert to adding code to v2.6 which is then ported back to v3 which has a new designer code base. So not really efficient wink

FetchPolymorphic is a static method, so I don't know what you're referring to?

Uh...good! smile

I briefly got cross thoughts from UC methods which are made as members - so I have to instantiate then call....

The main thing about the UC methods is that you're filling the instance you call the method on. The difference with the polymorphic fetch routine is that the row you're fetching might be for a different type, so it's not possible to fill the instance you call the method on.

<CompilerFeatureRequest> Microsoft Extension methods - I wish they would come up with a way in which I could make a static extension of a class, instead of an instance extension. This is the 2nd time I have wanted to do something like this. </CompilerFeatureRequest>

I don't think that makes much sense, or I might miss your point, because an extension method works on the data passed in which is always a set of instances. A static method which is for class C can be added in a partial class, or are you referring to the point where you want to add that static method to a class file OUTSIDE the project the original class is located in?

Anyway, I will probably just add a static method in the partial class of this currently one scenario I need it in....suprisingly this just has not come up before....

It has, but also after v2.6 was released.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 1263
Joined: 10-Mar-2006
# Posted on: 22-Dec-2008 16:46:08   

The main thing about the UC methods is that you're filling the instance you call the method on. The difference with the polymorphic fetch routine is that the row you're fetching might be for a different type, so it's not possible to fill the instance you call the method on.

Yeah, but for me, I either go;

MyEntity entity = new MyEntity(12); //creates new entity...

or I have to do:

MyEntity entity = new MyEntity(); //creates new entity... entity.UCBlah(12,34);

where I could possibly:

MyEntity entity = MyEntity.UCBlah(12, 34); //creates new entity...

are you referring to the point where you want to add that static method to a class file OUTSIDE the project the original class is located in

Exactly - like add one to the Image class that ships with .net.....

thanks, you guys are great.