How Do I Do this?

Posts   
 
    
LLBLGen
User
Posts: 43
Joined: 10-Apr-2006
# Posted on: 09-Jul-2006 01:50:27   

I have multiple Table that has these fields

"ChoiceCodeID" (int), "NodeID" (int) and "AllowDelete" (bit).

I need to write a function that returns the "AllowDelete" value from the Table i pass. How do i do this in LLBL.

Following is the way i have been doing for a Table CustomChoice. I am passing the "ChoiceCodeID" and "NodeID" and it returns me the "AllowDelete".

But instead of writting the function for each table i just want to pass the Table,ChoiceCodeID, NodeID and get the same result as follow:

something like GetAllowDelete(EntityBase2 TableName,int PassedCustomChoiceID,int PassedNodeID)....

---------------This is how i get the value from ChoiceCodeTable----

Public static bool GetAllowDelete(int PassedCustomChoiceID,int PassedNodeID) {

IRelationPredicateBucket filter = new RelationPredicateBucket(); filter.PredicateExpression.Add(PredicateFactory.CompareValue(CustomChoiceEntityFieldIndex.CustomChoiceID, ComparisonOperator.Equal, PassedCustomChoiceID)); filter.PredicateExpression.Add(PredicateFactory.CompareValue(CustomChoiceEntityFieldIndex.NodeID, ComparisonOperator.Equal, PassedNodeID));

DataAccessAdapter adapter = DataAccess.GetAdapter(); EntityCollection CustomChoiceCollection = new EntityCollection (new CustomChoiceEntityFactory()); adapter.FetchEntityCollection(CustomChoiceCollection,bucket); adapter.Dispose();

CustomChoiceEntity CustomChoice =new CustomChoiceEntity();

CustomChoice = (CustomChoiceEntity)CustomChoiceCollection[0]; return CustomChoice.AllowDelete; }

Thank you for your help.

Walaa avatar
Walaa
Support Team
Posts: 14987
Joined: 21-Aug-2005
# Posted on: 10-Jul-2006 14:24:29   

A similar question was asked here: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=6517

Another possibility is to use a database View that has those common fields and Unions all the tables using them, with the addition of a field that holds the each table name.

Then you can query this view by sending the table name with the other fields values.