Customer["Name"] instead of Customer.Name?

Posts   
 
    
9ppel
User
Posts: 17
Joined: 26-Feb-2007
# Posted on: 19-Jun-2007 09:27:35   

Hi

If I need to set a value in an entity-field based on a string containing the name of the field, can I use something like

string fieldName="Name"; Customer[fieldName] = "ACME Solutions";

or similar to this?

Customer is an LLBLGEN entity for the Customer database table.

Why? Because I'm going to make a program where the user can read values from an Excel-sheet into the database. Before this process starts the user can choose which column in the sheet should be saved in which field in the database. I would then like to use the fieldname as a key to set value to the correct database field. The alternative, as I see it, is to use a 'switch'-statment from h*ll.

(This is my first LLBLGEN PRO-project, btw. Soft start.)

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Jun-2007 10:06:12   

Please try Customer.Fields[fieldName]

9ppel
User
Posts: 17
Joined: 26-Feb-2007
# Posted on: 19-Jun-2007 10:09:36   

Great....thank you simple_smile

9ppel
User
Posts: 17
Joined: 26-Feb-2007
# Posted on: 19-Jun-2007 22:37:12   

Uhm, seems like what I was looking for was something else:

string fieldName="Name"; . . . . . Customer.SetNewFieldValue(fieldName, "Nomen Nescio"); Customer.Save();