Entity fields ordering

Posts   
 
    
BHerbert
User
Posts: 12
Joined: 16-Jul-2011
# Posted on: 18-Jul-2011 09:55:25   

Which object property gives the entity fields' ordering i.e the ordinal value for the table columns. I need to know the arrangement of columns as they are in the database because i am using reflection to call the insert method of each table thus need to arrange entity fields since they are arranged in alphabetical order not the databast table order ? try to adjust the template for Nhibernate to give me this ordinal value from the entity properties

Walaa avatar
Walaa
Support Team
Posts: 14986
Joined: 21-Aug-2005
# Posted on: 18-Jul-2011 10:30:56   

This is configurable from the Designer. Please check Field Ordering

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 18-Jul-2011 11:02:18   

How exactly do you use reflection in combination with nhibernate to create inserts? NHibernate doesn't have an ordinal field in the mappings btw, there's no 'order' in the field mappings according to nhibernate.

Frans Bouma | Lead developer LLBLGen Pro
BHerbert
User
Posts: 12
Joined: 16-Jul-2011
# Posted on: 18-Jul-2011 12:08:48   

Otis wrote:

How exactly do you use reflection in combination with nhibernate to create inserts? NHibernate doesn't have an ordinal field in the mappings btw, there's no 'order' in the field mappings according to nhibernate.

Okay i have a manager class for each table 'tablenameManager' which handles CRUD functions for the table, this manager class includes a method called Insert(params with same order as db table columns). Then i have another general method GeneralInsert(DataRow param) which calls the initializes the table manager class and calls the insert method using reflection based on the Datarow table name so here i pass the method parameters as an object array.

issue is the datarow passed to the general method doesn't always have rows arranged in the rigth way thus the insert method not matching the right parameter signatures.

so what i need is for the entityclass properties to be generated not in the alphabetical order but according to the underlying db table column ordinals so as when ever i receive the datatable object from the Client i check the relevant entityclass properties then based on the arrangement i will set the datatable column ordinals to set the datarow i send to the general insert method.

The entity field ordering option doesn't solve help me coz the properties are written to file in an alphabetical order in the entityclasses.

Walaa avatar
Walaa
Support Team
Posts: 14986
Joined: 21-Aug-2005
# Posted on: 18-Jul-2011 15:04:04   

AFAIK, reflection has nothing to do with how properties are written in a file, or in what order they are written. Same if some properties were written on another file (partial file).

I might be missing something here, but I'm not sure I'm following your arguments.