I have problem with subpath.add

Posts   
 
    
kem
User
Posts: 13
Joined: 13-Oct-2009
# Posted on: 02-Nov-2009 09:26:18   

When i add subpath to my IPrefetchPath2 pPath, error System.ArgumentException: The PrefetchPathElement you to tried to add is already added to this PrefetchPath. i thrown . The rest of the error message is:

System.ArgumentException: The PrefetchPathElement you to tried to add is already added to this PrefetchPath. Parametre name: elementToAdd location: SD.LLBLGen.Pro.ORMSupportClasses.PrefetchPath2.Add(IPrefetchPathElement2 elementToAdd, Int32 maxAmountOfItemsToReturn, IPredicateExpression additionalFilter, IRelationCollection additionalFilterRelations, ISortExpression additionalSorter, IEntityFactory2 entityFactoryToUse, ExcludeIncludeFieldsList excludedIncludedFields) location: SD.LLBLGen.Pro.ORMSupportClasses.PrefetchPath2.Add(IPrefetchPathElement2 elementToAdd) location: ....................................FirmaBilgileri.GetFirma(String firmaKey) ..............................\FirmaBilgileri.asmx.cs içinde: line 77

Let me explain i what i wantto do:

I have a table Firma which is in relation with FirmaIsyeri ( Firma - FirmaIsyeri (1:n) Field mapped: FirmaIsyerleri ) and FirmaIsyeri is in relation with FirmaIsletmeAdi ( FirmaIsyeri - FirmaIsletmeAdi (1:n) Field mapped: FirmaIsletmeAdi ) and OrtKisi ( FirmaIsyeri - OrtKisi (m:1) Field mapped: Kisi )

When i add those subpaths to my pPath i get the error i mentioned above.

Guid fKey = new Guid(firmaKey);
FirmaEntity firma = new FirmaEntity(fKey);
IPrefetchPath2 pPath = new PrefetchPath2((int)EntityType.FirmaEntity);
pPath.Add(FirmaEntity.PrefetchPathFirmaOrtaklari).SubPath.Add(FirmaOrtakEntity.PrefetchPathKisi); 
//pPath.Add(FirmaEntity.PrefetchPathFirmaSermaye).SubPath.Add(FirmaSermayeEntity.PrefetchPathFirmaSermayeOrtaklari);
            pPath.Add(FirmaEntity.PrefetchPathFirmaSozlesmeleri);
            pPath.Add(FirmaEntity.PrefetchPathFirmaSozlesmeleri).SubPath.Add(FirmaSozlesmeEntity.PrefetchPathFirmaSozlesmeMaddeleri);
            pPath.Add(FirmaEntity.PrefetchPathFirmaUnvanlari);
            pPath.Add(FirmaEntity.PrefetchPathFirmaYapilanIslem);

            pPath.Add(FirmaEntity.PrefetchPathFirmaAcentalar);
            pPath.Add(FirmaEntity.PrefetchPathFirmaAcentaliklar);
            pPath.Add(FirmaEntity.PrefetchPathFirmaAlinanBelgeler);
            pPath.Add(FirmaEntity.PrefetchPathFirmaAmacVeKonulari);
            pPath.Add(FirmaEntity.PrefetchPathFirmaAvukatBilgileri);
            pPath.Add(FirmaEntity.PrefetchPathFirmaAvukatBilgileri).SubPath.Add(FirmaAvukatBilgiEntity.PrefetchPathKisi);
            pPath.Add(FirmaEntity.PrefetchPathFirmaBagimliliklari);
            pPath.Add(FirmaEntity.PrefetchPathFirmaBirlesmeKapatılma);
            pPath.Add(FirmaEntity.PrefetchPathFirmaBirlesmeOlusma);
            pPath.Add(FirmaEntity.PrefetchPathFirmaBolunme);
            pPath.Add(FirmaEntity.PrefetchPathFirmaBolunmeDetay);
            pPath.Add(FirmaEntity.PrefetchPathFirmaDurumlari);
            pPath.Add(FirmaEntity.PrefetchPathFirmaGazeteBilgileri);
            pPath.Add(FirmaEntity.PrefetchPathFirmaGeciciTescilBilgileri);
            pPath.Add(FirmaEntity.PrefetchPathFirmaHarcBilgileri);
            pPath.Add(FirmaEntity.PrefetchPathFirmaHesapDonemleri);
            pPath.Add(FirmaEntity.PrefetchPathFirmaIlanlari);
            pPath.Add(FirmaEntity.PrefetchPathFirmaIntibakBildirimleri);
            pPath.Add(FirmaEntity.PrefetchPathFirmaIsletmeAdi);
            pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri);
            pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri).SubPath.Add(FirmaIsyeriEntity.PrefetchPathFirmaIsletmeAdi);
            pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri).SubPath.Add(FirmaIsyeriEntity.PrefetchPathKisi); // Rigth here eror is thrown 

pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri).SubPath.Add(FirmaIsyeriEntity.PrefetchPathKisi); // Rigth here eror is thrown

How can i do this, add all those paths.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Nov-2009 10:31:48   
        pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri).SubPath.Add(FirmaIsyeriEntity.PrefetchPathFirmaIsletmeAdi);
        pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri).SubPath.Add(FirmaIsyeriEntity.PrefetchPathKisi); // Rigth here eror is thrown 

Instead of the above do the following:

            IPrefetchPathElement2 pathElement = pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri);

            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathFirmaIsletmeAdi);
            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathKisi);
kem
User
Posts: 13
Joined: 13-Oct-2009
# Posted on: 02-Nov-2009 15:58:04   

So what will i do with pathElement. How can i prefetch it while i have some other prefetchpaths such as pPath.Add(FirmaEntity.PrefetchPathFirmaAlinanBelgeler); pPath.Add(FirmaEntity.PrefetchPathFirmaAmacVeKonulari); pPath.Add(FirmaEntity.PrefetchPathFirmaAvukatBilgileri); that has nothing to do with FirmaIsyeriEntity. They are completely different entities then FirmaIsyeriEntity. How can i prefetch all those different entities? How will i combine different subpathes when i prefetch them?

Here is how i prefetched them previously DbAdapter.FetchEntity(firma,pPath );

Thanks.

Walaa wrote:

        pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri).SubPath.Add(FirmaIsyeriEntity.PrefetchPathFirmaIsletmeAdi);
        pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri).SubPath.Add(FirmaIsyeriEntity.PrefetchPathKisi); // Rigth here eror is thrown 

Instead of the above do the following:

            IPrefetchPathElement2 pathElement = pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri);

            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathFirmaIsletmeAdi);
            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathKisi);
Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Nov-2009 16:26:30   

You only use the PrefetchPath instance as you have used it beofre.

The PrefetchPathElement is returned from the Add() method to let you add several subPaths as shown in the example I've posted before.

kem
User
Posts: 13
Joined: 13-Oct-2009
# Posted on: 03-Nov-2009 10:56:59   

There is a little problem.

I create an instance of pathElement that refers to pPath i have used before. However after i add subpathes to pathElement, never used it, because i have used DbAdapter.FetchEntity(firma,pPath ); as i have before. So where should i use pathElement element? Don't i need to relate it to my DahaAdapter's fetch method in a way?

Walaa wrote:

You only use the PrefetchPath instance as you have used it beofre.

The PrefetchPathElement is returned from the Add() method to let you add several subPaths as shown in the example I've posted before.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 03-Nov-2009 11:03:28   
            IPrefetchPathElement2 pathElement = pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri);

            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathFirmaIsletmeAdi);
            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathKisi);

Let's take the above code for example.

the pathElement is just a reference to the element added to the pPath, so whatever you add using pathElement.SubPath.Add(), is actually adding them to the element inside the pPath.

In other words pathElement is just a reference to an element inside the pPath. So you need to do nothing afterwards if you are using the pPath.

kem
User
Posts: 13
Joined: 13-Oct-2009
# Posted on: 03-Nov-2009 16:50:58   

Now clear, got it, thanks...

Walaa wrote:

            IPrefetchPathElement2 pathElement = pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri);

            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathFirmaIsletmeAdi);
            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathKisi);

Let's take the above code for example.

the pathElement is just a reference to the element added to the pPath, so whatever you add using pathElement.SubPath.Add(), is actually adding them to the element inside the pPath.

In other words pathElement is just a reference to an element inside the pPath. So you need to do nothing afterwards if you are using the pPath.

kem
User
Posts: 13
Joined: 13-Oct-2009
# Posted on: 04-Nov-2009 16:00:47   

Well, tried the following code however i couldn't get the second collection-_FirmaSermayeKarsilanmalari_- in XML of of my webservice as if ididn't add the to subpath:

 IPrefetchPathElement2 pathElementSermaye = pPath.Add(FirmaEntity.PrefetchPathFirmaSermaye);
pathElementSermaye.SubPath.Add(FirmaSermayeEntity.PrefetchPathFirmaSermayeOrtaklari);
 pathElementSermaye.SubPath.Add(FirmaSermayeEntity.PrefetchPathFirmaSermayeKarsilanmalari); 

pathElementSermaye.SubPath.Add(FirmaSermayeEntity.PrefetchPathFirmaSermayeKarsilanmalari); // Righ here i cannot fetch in above code

Here is how i fetch my collection -sample not the whole-

FirmaEntity firma = new FirmaEntity(fKey);
IPrefetchPath2 pPath = new PrefetchPath2((int)EntityType.FirmaEntity);
pPath.Add(FirmaEntity.PrefetchPathFirmaAcentalar);
pPath.Add(FirmaEntity.PrefetchPathFirmaAcentaliklar);
pPath.Add(FirmaEntity.PrefetchPathFirmaAlinanBelgeler); 
pPath.Add(FirmaEntity.PrefetchPathFirmaAmacVeKonulari);
pPath.Add(FirmaEntity.PrefetchPathFirmaAvukatBilgileri).SubPath.Add(FirmaAvukatBilgiEntity.PrefetchPathKisi);
pPath.Add(FirmaEntity.PrefetchPathFirmaBagimliliklari);
pPath.Add(FirmaEntity.PrefetchPathFirmaBirlesmeKapatılma);
pPath.Add(FirmaEntity.PrefetchPathFirmaBirlesmeOlusma);
pPath.Add(FirmaEntity.PrefetchPathFirmaSektorleri).SubPath.Add(FirmaSektorEntity.PrefetchPathSektorTuru);

// HERE
IPrefetchPathElement2 pathElementSermaye = pPath.Add(FirmaEntity.PrefetchPathFirmaSermaye);
pathElementSermaye.SubPath.Add(FirmaSermayeEntity.PrefetchPathFirmaSermayeOrtaklari);
pathElementSermaye.SubPath.Add(FirmaSermayeEntity.PrefetchPathFirmaSermayeKarsilanmalari);
//UPTO HERE


pPath.Add(FirmaEntity.PrefetchPathFirmaTerkinleri).SubPath.Add(FirmaTerkinEntity.PrefetchPathFirmaTerkinNedenleriTuru);   
pPath.Add(FirmaEntity.PrefetchPathFirmaUnvanlari);
pPath.Add(FirmaEntity.PrefetchPathFirmaYapilanIslem);

DbAdapter.FetchEntity(firma,pPath );
            

Thanks...

Walaa wrote:

            IPrefetchPathElement2 pathElement = pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri);

            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathFirmaIsletmeAdi);
            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathKisi);

Let's take the above code for example.

the pathElement is just a reference to the element added to the pPath, so whatever you add using pathElement.SubPath.Add(), is actually adding them to the element inside the pPath.

In other words pathElement is just a reference to an element inside the pPath. So you need to do nothing afterwards if you are using the pPath.

kem
User
Posts: 13
Joined: 13-Oct-2009
# Posted on: 04-Nov-2009 16:11:11   

It it ok, resolved, thanks alot...

Walaa wrote:

            IPrefetchPathElement2 pathElement = pPath.Add(FirmaEntity.PrefetchPathFirmaIsyerleri);

            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathFirmaIsletmeAdi);
            pathElement.SubPath.Add(FirmaIsyeriEntity.PrefetchPathKisi);

Let's take the above code for example.

the pathElement is just a reference to the element added to the pPath, so whatever you add using pathElement.SubPath.Add(), is actually adding them to the element inside the pPath.

In other words pathElement is just a reference to an element inside the pPath. So you need to do nothing afterwards if you are using the pPath.