Lookup Value Binding

Posts   
 
    
dpanet
User
Posts: 14
Joined: 31-Oct-2006
# Posted on: 13-Nov-2006 16:48:08   

I'm evaluating your product, and I really couldn't figure out how to display a Look up value from another related table.

For example, I have the OrderDetails and Product related thru ProductId and I want to display the ProductName in the fetched OrderDetails Collection in my gridview.

the only way it seems is to create a dynamic list, like this

        DataAccessAdapter adapter = new DataAccessAdapter(false);
        ResultsetFields fields = new ResultsetFields(3);
        fields.DefineField(OrderDetailsFields.OrderId,0,"OrderID");
        fields.DefineField(ProductsFields.ProductName, 1, "ProductName");
        fields.DefineField(OrderDetailsFields.Quantity, 2, "Quantity");
        IRelationPredicateBucket bucket = new RelationPredicateBucket();
        bucket.Relations.Add(OrderDetailsEntity.Relations.ProductsEntityUsingProductId);
        DataTable dynamicList = new DataTable();
        adapter.FetchTypedList(fields, dynamicList, bucket, false);

but I wish somehow to just say display the value from OrderDetails.Product.ProductName and bind it to my gridview with the rest of OrderDetails columns.

is it possible , and is there an easy way ?.

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 13-Nov-2006 17:10:41   

Hello,

if you are always use the sames fields, you can also use "Fields Mapped on related fields".

For that, go to the LLBLGen Pro Designer, open the properties of the your Entity(here "Order"). Go to the Fields mapped on related fields sub tab and add the fields of your related table(here ProductName from the Product Table). If you bind the entitycollection of your modified entity, it would be good but you have to make this before generation.