Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> The multi-part identifier "[Alias].[entity] " could not be bound
 

Pages: 1
Bugs & Issues
The multi-part identifier "[Alias].[entity] " could not be bound
Page:1/1 

  Print all messages in this thread  
Poster Message
jvdboom
User



Location:

Joined on:
22-May-2007 14:54:10
Posted:
28 posts
# Posted on: 31-Jan-2008 10:58:49. Goto attachments  
Hello i have read a lot about this error in this forum but i can not use to answers to get a solution.

The database i use is from a customer with strange m:n relations in it. This is the first time for me i have to deal with a n:m relationship.

llblgen version = 2.5 final

the sql(2005 express)server script i use: see attachement


The code i use:

        private static void ShowMailPiecesJob(XmlNodeList aMailPieceList, decimal aIdentityCommon) {

            JobsEntity job = new JobsEntity();
            IPredicateExpression filter = new PredicateExpression().Add(JobsFields.IdentityCommon.SetObjectAlias("JobsIdentityCommon") == aIdentityCommon);
            MailPiecesCollection mailPieces = job.GetMultiMailPieces(true, filter);

            foreach(MailPiecesEntity mailPiece in mailPieces){
                Console.Write(mailPiece.JobsId.ToString());
            }

            
        }

The error i get:
31-1-2008 9:55:40:
SD.LLBLGen.Pro.ORMSupportClasses.NET20

An exception was caught during the execution of a retrieval query: The multi-part identifier "aIdentityCommon.IdentityCommon" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.

An exception was caught during the execution of a retrieval query: The multi-part identifier "aIdentityCommon.IdentityCommon" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.

at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityCollection collectionToFill, Boolean allowDuplicates, IEntityFields fieldsUsedForQuery, IFieldPersistenceInfo[] fieldPersistenceInfos)
at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
at StaterDal.DaoClasses.MailPieceDAO.GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IPredicateExpression filter, IEntity jobInstance, Int32 pageNumber, Int32 pageSize) in C:\Stater\DAL\DaoClasses\MailPieceDAO.cs:line 77
at StaterDal.CollectionClasses.MailPieceCollection.GetMultiManyToOne(IEntity jobInstance, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicateExpression filter, Int32 pageNumber, Int32 pageSize) in C:\Stater\DAL\CollectionClasses\MailPieceCollection.cs:line 115
at StaterDal.CollectionClasses.MailPieceCollection.GetMultiManyToOne(IEntity jobInstance, IPredicateExpression filter) in C:\Stater\DAL\CollectionClasses\MailPieceCollection.cs:line 78
at StaterDal.EntityClasses.JobEntity.GetMultiMailPiece(Boolean forceFetch, IEntityFactory entityFactoryToUse, IPredicateExpression filter) in C:\Stater\DAL\EntityClasses\JobEntity.cs:line 446
at StaterDal.EntityClasses.JobEntity.GetMultiMailPiece(Boolean forceFetch, IPredicateExpression filter) in C:\Stater\DAL\EntityClasses\JobEntity.cs:line 413
at Stater.Program.SaveJobsMailPieces(XmlNodeList aMailPieceList, Decimal aIdentityCommon) in C:\Stater\Stater\Program.cs:line 52
at Stater.Program.Main(String[] args) in C:\Stater\Stater\Program.cs:line 41

I try to get the mailpieces with a give identityCommon.
I generated SelfServing classes.

Probably i make a beginner mistake i hope you know which one.

Thanx for reading this.

Jos


  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 31-Jan-2008 11:12:47.  
Why do you use an alias in the predicate? (SetObjectAlias("JobsIdentityCommon"))

Try without it.


  Top
jvdboom
User



Location:

Joined on:
22-May-2007 14:54:10
Posted:
28 posts
# Posted on: 31-Jan-2008 12:43:16.  
Thank you for the quick response.
I already did tha with this code. then I had the same error. I visited this forem and tried it the why i send you earlier. The result is the same.

private static void SaveJobsMailPieces(XmlNodeList aMailPieceList, decimal aIdentityCommon) {

            JobsEntity job = new JobsEntity();
            IPredicateExpression filter = new PredicateExpression();
            filter.Add(JobsFields.IdentityCommon == aIdentityCommon);

            MailPiecesCollection mailPieces = job.GetMultiMailPieces(true, filter);

            foreach(MailPiecesEntity mailPiece in mailPieces){
                Console.Write(mailPiece.JobsId.ToString());
            }

            
        }
}

Jos
  Top
TomV
User



Location:
Belgium
Joined on:
31-Jan-2008 14:22:10
Posted:
76 posts
# Posted on: 31-Jan-2008 14:23:44.  
I have the same error.
So I'm also waiting for a solution or hint...

Kind regards
TomV


Life goes fast, it must be riding a Ducati!  Top
jvdboom
User



Location:

Joined on:
22-May-2007 14:54:10
Posted:
28 posts
# Posted on: 31-Jan-2008 14:52:26.  
I simplified the database by making most fields nullable.
I added a Rowguid.

See the document for the relations.
See the sql for the new script.

Jos

  Top
jvdboom
User



Location:

Joined on:
22-May-2007 14:54:10
Posted:
28 posts
# Posted on: 31-Jan-2008 14:53:43.  
I simplified the database by making most fields nullable.
I added a Rowguid.

See the document for the relations.
See the sql for the new script.

Jos



  Top
jvdboom
User



Location:

Joined on:
22-May-2007 14:54:10
Posted:
28 posts
# Posted on: 31-Jan-2008 14:53:49.  
I simplified the database by making most fields nullable.
I added a Rowguid.

See the document for the relations.
See the sql for the new script.

Jos

  Top
jvdboom
User



Location:

Joined on:
22-May-2007 14:54:10
Posted:
28 posts
# Posted on: 31-Jan-2008 14:59:30. Goto attachments  
Sorry firewall problems here.





  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 31-Jan-2008 15:23:16.  
Quote:
private static void SaveJobsMailPieces(XmlNodeList aMailPieceList, decimal aIdentityCommon) {

            JobsEntity job = new JobsEntity();
            IPredicateExpression filter = new PredicateExpression();
            filter.Add(JobsFields.IdentityCommon == aIdentityCommon);

            MailPiecesCollection mailPieces = job.GetMultiMailPieces(true, filter);

            foreach(MailPiecesEntity mailPiece in mailPieces){
                Console.Write(mailPiece.JobsId.ToString());
            }            
        }
}

When you call:
MailPiecesCollection mailPieces = job.GetMultiMailPieces(true, filter);
Automatically a filter is used to filter the MailPieces returned by comparing the MailPieces.JobsId (FK) to the value of the PK of the job entity.

And that's it.
Now you want to add another filter to the GetMulti of the MailPieces but this filter is referencing another table, which by the way is the JobsEntity itself.
But then you will need to pass the relation (JOIN) to let the GetMulti filter upon another table.

And that's not available in the builtIn job.GetMultiMailPieces() overloads.

Also note that you are using a new Jobs Entity, which doesn't have a PK set.

Anyway what you can do is the following:

Code:
private static void SaveJobsMailPieces(XmlNodeList aMailPieceList, decimal aIdentityCommon) {

            IPredicateExpression filter = new PredicateExpression();
            filter.Add(JobsFields.IdentityCommon == aIdentityCommon);

            RelationCollection relations = new RelationCollection();
            relations.Add(MailPiecesEntity.Relations.JobEntity...);

            MailPiecesCollection mailPieces = new MailPiecesCollection();
            mailPiece.GetMulti(filter, relations);

            // or use the following if you want to fetch the collection into the job.MailPieces
            JobsEntity job = new JobsEntity();
            job.mailPiece.GetMulti(filter, relations);

            foreach(MailPiecesEntity mailPiece in mailPieces){
                Console.Write(mailPiece.JobsId.ToString());
            }            
        }
}


  Top
jvdboom
User



Location:

Joined on:
22-May-2007 14:54:10
Posted:
28 posts
# Posted on: 31-Jan-2008 15:45:18.  
Thanx! This works.

But now i know that i have to read all the documentation about n:m relations.
Because 1:n relations are covered very well in documentation and examples but the examples about n:m relations editing, updating and deleting are like a 'spelt in een hooiberg' this is a dutch expression Regular Smiley for you have to look for them very well and if you're lucky maybe you find one.

Greetings,
Jos


  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37812 posts
# Posted on: 31-Jan-2008 16:07:53.  
"needle in a haystack " Wink

M:N relations are a view on 2 1:n relations, so it's actually not that hard, though it can be confusing IF you see an m:n relation as a relation where just 2 entities are involved, not 3. You then won't update the intermediate entity and things will go wrong.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
jvdboom
User



Location:

Joined on:
22-May-2007 14:54:10
Posted:
28 posts
# Posted on: 31-Jan-2008 16:20:54. Goto attachments  
Hoi Otis,

Thanx for trying to simplify the n:m relationship Laugh

But for me, i'm used to Entity.GetMulti().... this is still Confused

And if you look at the Database Relations i don't even know where to begin saving a record and so working my way around. But you gave a little hint of were the needle may be Wink

Greetings,
Jos






  Top
TomV
User



Location:
Belgium
Joined on:
31-Jan-2008 14:22:10
Posted:
76 posts
# Posted on: 31-Jan-2008 18:11:08.  
My problem is solved, but now I have another one, I assume it doesn't belong here, but I search on the forum and didn't found anything...

My code:

            EntityCollection<TranslationEntity> Translations = new EntityCollection<TranslationEntity>();

            IPrefetchPath2 path = new PrefetchPath2(EntityType.TranslationEntity);
            path.Add(TranslationEntity.PrefetchPathTranslationValues);

            RelationPredicateBucket bucket = new RelationPredicateBucket();
            bucket.Relations.Add (TranslationEntity.Relations.TranslationValueEntityUsingTranslationId);
            bucket.PredicateExpression.Add(TranslationValueFields.LanguageId == 1);

            using (IDataAccessAdapter adapter = DataAccessFactory.GetAdapter())
            {
             adapter.FetchEntityCollection(Translations, bucket);
            }

My problem:

per TranslationEntity I have 5 related TranslationValueEntities. But when I know the language of the user, I only want 1 language/corresponding record to be retrieved...
But when I use above code, all 5 related records are retrieved...
==> Translations[0].TranslationValues.Count = 5

I don't see what I do wrong. Can you help me please?

Kind regards
TomV
Life goes fast, it must be riding a Ducati!  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 01-Feb-2008 10:53:21.  
First of all, you are not using the PrefetchPath in the fetch method.

And then when you do, if you want to filter the prefetched related entities, then use the filter on the preftechPath itself not in the main fetch method.

Code:
            EntityCollection<TranslationEntity> Translations = new EntityCollection<TranslationEntity>();

            PredicateExpression prefetchFilter = new PredicateExpression(TranslationValueFields.LanguageId == 1);

            IPrefetchPath2 path = new PrefetchPath2(EntityType.TranslationEntity);
            path.Add(TranslationEntity.PrefetchPathTranslationValues, 0, prefetchFilter);

            using (IDataAccessAdapter adapter = DataAccessFactory.GetAdapter())
            {
             adapter.FetchEntityCollection(Translations, null, path);
            }


  Top
TomV
User



Location:
Belgium
Joined on:
31-Jan-2008 14:22:10
Posted:
76 posts
# Posted on: 01-Feb-2008 11:03:37.  
Thanks!! This solved my problem! Laugh
Now when I see your solution it's quite obvious to use the filter in the PrefetchPath, but as always, you have to know... Cool

I was mislead by the example in the user manual (page 257 - 258: Advanced Prefetch Paths).

btw, not using the prefetch path was a copy - paste error Sad

Further I just want to say that LLBLGenPro really rocks!
I have my license since this week and I already love it!

Kind regards
TomV
Life goes fast, it must be riding a Ducati!  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 01-Feb-2008 11:37:59.  
Thanks for the positive feedback, and I hope you always stay glad with LLBLGen Pro Regular Smiley

  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.