multi-part identifier "tblName.XId" could not be bound

Posts   
 
    
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 09-May-2006 23:48:55   

< self servicing winforms 2005

hiya,

I am getting the above error with the code below.I've no idea why.Has anyone had anything similar before?

many thanks,

yogi


IPredicateExpression filtReturnProductCondition = new PredicateExpression();
filtReturnProductCondition.Add(PredicateFactory.CompareValue(TblReturnProductsFieldIndex.ReturnProductCondtionId, ComparisonOperator.Equal, (int)cboReturnProductCondition.SelectedValue));
            
filtReturnProductCondition.Add(PredicateFactory.CompareValue(TblReturnProductsFieldIndex.ReturnId, ComparisonOperator.Equal, _selectedReturnId));   

tblReturnCollection1.Clear();
tblReturnCollection1.GetMulti(filtReturnProductCondition);

 dgvReturns.DataSource = tblAddedReturnsBindingSource;      

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 10-May-2006 20:38:56   

It's likely that you refer to a field in a related entity which isn't found, so you refer to customer.CompanyName, when an order entity is bound, and the order doesn't have a customer property.

Frans Bouma | Lead developer LLBLGen Pro
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 10-May-2006 23:55:03   

hiya Frans,

You're right. It means that I have an issue :-(

I have a datagridView. (this datagridView is not populated via the IDE)

There is a top level bindingSource, let's just call it "tblReturnsBindingSource"

tblReturnsBindingSource.datasource = tblReturnCollection1

Then, we have the "child" binding source...which is actually bound to the datagridview.

"tblReturnsProductsBindingSource"

tblReturnsProductsBindingSource.datamember = tblReturnProducts //THIS IS WHAT i NEED TO FILTER

tblReturnsProductsBindingSource.dataSource = tblReturnsBindingSource

So, I want to filter the "child" entity collection, namely the "tblReturnProducts"

Therefore, I believe that my filter predicate code is OK, but WHAT do I apply it to? Please let me know if i can clarify anything. simple_smile


IPredicateExpression filtReturnProductCondition = new PredicateExpression();
            filtReturnProductCondition.Add(PredicateFactory.CompareValue(TblReturnProductsFieldIndex.ReturnProductCondtionId, ComparisonOperator.Equal, (int)cboReturnProductCondition.SelectedValue));
            filtReturnProductCondition.Add(PredicateFactory.CompareValue(TblReturnProductsFieldIndex.ReturnId, ComparisonOperator.Equal, _selectedReturnId));  

etc,
etc
    dgvReturns.DataSource = tblReturnsProductsBindingSource;  

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 11-May-2006 07:47:09   

So, I want to filter the "child" entity collection, namely the "tblReturnProducts" Therefore, I believe that my filter predicate code is OK, but WHAT do I apply it to?

I'm afraid I don't understand what are you trying to do?

Do you want to filter entities from the database? if so then you had the correct code. Do you want to filter related entities from the database? then fecth the main entities with add a prefetchPath that contains the filter.

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 11-May-2006 10:51:06   

hiya Walaa

Yes,

I want to filter entities from the database. However, I DON’T have the correct code, because I haven’t actually applied the filter to anything yet.

That is what I am struggling with.

dgvReturns.DataSource = tblReturnsProductsBindingSource;

So, the datgridView is bound to a bindingSource. The bindingSource is bound to a PARENT bindingSource. This parentBindingSource contains the entityCollection (that I want to filter) as a datamember.

My question: I have the correct predicate (as you know).

How do I apply it to the datamember of the parentBindingSource?

I hope this makes more sense smile

yogi

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 11-May-2006 14:53:50   

I see, I guess you are trying to filter a collection after it has been fetched from the database, not as I thought earlier (filter results when fetching from the database).

With V.1 you have no way to filter an entity collection in memory, except by manually traversing it.

But with V.2 you may use an EntityView to filter an EntityCollection.

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 11-May-2006 18:29:35   

Ok, I see that V2 is due for release in 2nd quarter.

I'm confused when you say "manually traverse the entityCollection in memory'

Yes, as it stands, I would be looking to filter the entityCollection AFTER it has been retrieved from the database.

However, this is only because the only way to set up the functionality I need is thru the IDE.

Would it be possible to set up the same functionality via code?

I have absolutely no qualms about re querying the database everytime that I need to filter the data

(this is my first, small project, on a single machine) so I don't need to worry about hitting the database a few extra times stuck_out_tongue_winking_eye

many thanks,

yogi

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 12-May-2006 08:02:03   

I'm confused when you say "manually traverse the entityCollection in memory'

I mean looping inside the entitycollection and examining each entity to see if it meats your filter or not.

foreach (MyEntity myEntity in MyEntityCollection)
{
    if (myEntity.Field1 > ....) // any filtering conditions
    {
         // do something, probably adding this entity to another collection of filtered entities
     }                  
}

Would it be possible to set up the same functionality via code?

Refetch the collection using the filter, and re-bind.

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 15-May-2006 21:34:04   

hiya Walaa.

I'm still confused about how I get access to this child entityCollection. The datagridview is bound to the parent entityCollection. The datagridView dataMember is set to the child entityCollection.

So, I want to filter the child entityCollection.

I tried looking for it via intellisense in the parent entityCollection, but nothing.

Does this make sense?

many thanks,

yogi

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 16-May-2006 15:31:34   

I tried looking for it via intellisense in the parent entityCollection, but nothing.

Ok the child collection is a member of the Entities inside the parent collection, not a member of the parent collection itself.

So to access it you need to cast an item of the entitycollection to its supposed type, and then you'll find the member entitycollection by intellisense

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 17-May-2006 00:26:55   

hiya Walaa,

Ok, I have had trouble casting to the appropriate type. Below is what I have, but I think that I need to take the approach you mentioned when you said...

Ok the child collection is a member of the Entities inside the parent collection, not a member of the parent collection itself.

So to access it you need to cast an item of the entitycollection to its supposed type, and then you'll find the member entitycollection by intellisense

That is the problem though, I'm not sure how to do it. Any help appreciated.

Cheers,

yogi



foreach (childEntity   currDeliveryProduct in parentEntityCollection1)
            {
                if (currDeliveryProduct.ReturnId == _selectedReturnId )
                {
                     // do something, probably adding this entity to another collection of filtered entities
                }
            }


Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 17-May-2006 07:48:06   

foreach (ParentEntity P in parentEntityCollection1)
{
    foreach (ChildEntity C in P.ChildEntityCollection)
    {
        if (C.ReturnId == _selectedReturnId )
        {
            // do something, probably adding this entity to another collection of filtered entities
         }
    }
}

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 18-May-2006 23:11:57   

cheers Walaa,

The code successfully finds the child entities that I want to KEEP in the entityCollection.

However, I have ALREADY databound the datgridView. (via the IDE) So, do I scratch the original databind?

By the way, I can start a new thread, if it would make things clearer??

Many thanks,

yogi


 foreach (TblReturnEntity currReturnsEntity in tblReturnCollection1)
            {
                foreach (TblReturnProductsEntity currReturnsProduct in currReturnsEntity.TblReturnProducts)
                {
                    if (currReturnsProduct.ReturnId == _selectedReturnId && currReturnsProduct.ReturnProductCondtionId == (int)cboReturnProductCondition.SelectedValue)
                    {
                                              // do something, probably adding this entity to another collection of filtered entities
                    }
                    }
            }


However,

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-May-2006 09:26:27   

By the way, I can start a new thread, if it would make things clearer??

Yeah a good idea, as I get confused whenever I try to read the thread from start to end.