Order of fields generated out of the database

Posts   
 
    
orenpeled
User
Posts: 53
Joined: 25-Jul-2005
# Posted on: 25-Jul-2005 10:10:39   

Hi everyone,

I need to know how fields are generated out of my Oracle database.

To be more clear, I'll give an example:

I have created the table customer with the following command: CREATE TABLE COUNTRY(NAME VARCHAR2(32), NUMBER_OF_CITIZENS NUMBER); After generating the code with LLBLGen, I've noticed that in order to get the 'NAME' field I should call countryEntity.Fields[0] and in order to get the 'NUMBER_OF_CITIZENS' field I should call countryEntity.Fields[1]. The CountryFieldIndex is respectively: public enum CountryEntityIndex:int { Name, NumberOfCitizens, AmountOfFields }

Now, is this a mandatory rule? The order of the fields in my Oracle database, as I have created, will alway be reflected in the LLBLGen code?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 25-Jul-2005 12:46:36   

Yes, though you should either use the enums, or the properties, not numeric indices into the field object. That's not compiler-save, for example when a field changes name, you insert a field etc.

Frans Bouma | Lead developer LLBLGen Pro
orenpeled
User
Posts: 53
Joined: 25-Jul-2005
# Posted on: 25-Jul-2005 13:24:04   

I am aware of the fact that using field indices is not compiler-safe, but in my application I need to perform insert operations with a different engine (ArcObjects for that matter) and only with this engine (I work with geographic data - that's why I cannot accomplish an insert operation with LLBLGen, I use LLBLGen as a mid-data-layer) - I want to perform a full insert operation in one database-transaction. Assuming the other engine keeps the order of the fields, as LLBLGen does, I want to perform a conversion based on the field indices, it seems that it's the best way. Unfortunatelly, I couldn't find how to reference fields by their database-name ("NUMBER_OF_CITIZENS" and not "NumberOfCitizens") - that would make it much easier for me to perform the conversion... Or maybe I am missing something?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 26-Jul-2005 11:19:56   

If you want to keep teh field names as the names of the db fields they're mapped on, go to the preferences and set the following options to the following values: under name construction: - MakeElementNamePascalCasing : false - RemoveUnderscoresFromElementName: false under catalog refresher: - SyncMappedElementNamesAfterRefresh: true

Frans Bouma | Lead developer LLBLGen Pro