LivePersistence=false and TypedList example? (Adapter)

Posts   
 
    
ChrisCY
User
Posts: 22
Joined: 20-Jun-2007
# Posted on: 14-May-2009 09:58:26   

Hi all,

I am implementing an ASP.NET 2.0 (C#) application using LLBLGen 2.6 and the Adapter template with an Oracle 10g backend.

I have a scenario where I want to Insert/Update data using a vanilla FormView. These data reside in two tables in the DB and are connected with a Foreign Key relation. What I want is to be able to Insert/Update all the fields of the two tables using a single FormView.

I have entities mapped on the two tables. I though that I should approach this by creating a typed list with the combination of the fields of the two tables, bind the FormView on the DataSource (configured with the typed list) and handle the distribution of the data in "PerformWork" using LivePersistence=false.

But I haven't been able to implement it because of two showstoppers (so far!) in "PerformSelect":

1) I set the ID of the Entity through code-behind by setting a Predicate in the "FiltertoUse" property of the datasourse. How do I add that predicate to my adapter since I have to use myTypedList.GetRelationInfo() as filter

2) How do I transfer the retrieved data from my adapter to the DataSource? I get an error that "e.ContainedTypedList" is read-only!

I tried various code snippets that I found in the forum but nothing worked and I don't know what I am doing wrong.

Any directions will be greatly appreciated. Thanks in advance!

Chris

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 14-May-2009 10:57:29   

1) I set the ID of the Entity through code-behind by setting a Predicate in the "FiltertoUse" property of the datasourse. How do I add that predicate to my adapter since I have to use myTypedList.GetRelationInfo() as filter

IRelationPredicateBucket bucket = myTypedList.GetRelationInfo();
bucket.PredicateExpression.Add(/*ADD ANY FILTER YOU WANT*/);

Then use this bucket in the adapter fetch method.

2) How do I transfer the retrieved data from my adapter to the DataSource? I get an error that "e.ContainedTypedList" is read-only!

Please use mydataSource.TypedList property

ChrisCY
User
Posts: 22
Joined: 20-Jun-2007
# Posted on: 14-May-2009 11:21:46   

Thanks for the quick reply!

Regarding the first issue, by the time "PerformSelect" is called, I have already set the predicate I need to the FilterToUse property of the datasource. I expect this to be available through the "e.Filter" property which is an "IRelationPredicateBucket". How do I extract the "IPredicate" object to add it to the TypedList PredicateExpression?

I want to avoid having controls laying around just for the sake of transferring the ID value in "PerformSelect".

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 14-May-2009 11:32:53   

Regarding the first issue, by the time "PerformSelect" is called, I have already set the predicate I need to the FilterToUse property of the datasource. I expect this to be available through the "e.Filter" property which is an "IRelationPredicateBucket". How do I extract the "IPredicate" object to add it to the TypedList PredicateExpression?

Why do you wanna do that? Aren't you selecting from a TypedList, then you try to update the involved entities? So as far as I understand you shouldn't add any redicate in the PerformSelect, right?

Anyway you can grab the Predicate expression as follows:

e.Filter.PredicateExpression
ChrisCY
User
Posts: 22
Joined: 20-Jun-2007
# Posted on: 14-May-2009 12:04:34   

Well, my intention is to update an entity with a specific ID, thus I need to add a predicate that states that ID==<value>.

Anyway, your suggestions worked like charm! I now have to find out what to do in "PerformWork" smile

Thanks again for all the help!