Column name case

Posts   
 
    
rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 06-Sep-2005 20:06:00   

Hi this is a follow on from another query I had... I want to loop through a row creating entities from this row and then adding the entity to the collection object..

When I loop through the row the first column throws an exception saying the column name does not exist.. I found the reason, the column name is called OutboundMessageID (note the ID case) BUT the entity get/set member is OutboundMessageId, (ie small d)..

I think is the cause of the exception from the loop below..

I have generated the code with the MakeElementNamePascalCasing in case this was causing the problem however this problem occurs with this set to either true or false..

If anyone can help then I would appreciate it, obviously I can set each member of the entity seperately however this entity may change and I dont want to keep updating this piece of code hence the loop.

Many thanks

Richard

OutboundMessagesEntity entity = (OutboundMessagesEntity)collection.AddNew(); foreach(DataColumn column in table.Columns) { entity.SetNewFieldValue(column.ColumnName, row[column]); }

Paul.Lewis
User
Posts: 147
Joined: 22-Aug-2005
# Posted on: 07-Sep-2005 04:19:27   

rparkins wrote:

I want to loop through a row creating entities from this row and then adding the entity to the collection object..

Consider reading the data directly into the entity collection. This would be much more efficient.

rparkins wrote:

When I loop through the row the first column throws an exception saying the column name does not exist.. I found the reason, the column name is called OutboundMessageID (note the ID case) BUT the entity get/set member is OutboundMessageId, (ie small d)..

Are you using an "AS OutboundMessageID" in the query that loads data into your data table? This would explain why the LLBLGen generated code is different from the column name.

rparkins
User
Posts: 66
Joined: 04-May-2005
# Posted on: 07-Sep-2005 09:44:21   

Hi Paul thanks for your reply.. I am doing a select * in the stored procedure query.

Also (new to this stuff relatively and only use a subset of what this stuff can do) how do I load the data directly into the entity from each row?

Regards

Richard

Paul.Lewis
User
Posts: 147
Joined: 22-Aug-2005
# Posted on: 08-Sep-2005 04:46:26   

rparkins wrote:

Hi Paul thanks for your reply.. I am doing a select * in the stored procedure query.

It was worth a try...

rparkins wrote:

Also (new to this stuff relatively and only use a subset of what this stuff can do) how do I load the data directly into the entity from each row?

Here's a simple example from the LLBLGen User Manual page: Generated code - Using the entity collection classes, SelfServicing

It reads all orders into the orders collection without filtering or sorting

// [C#]

OrderCollection orders = new OrderCollection();
orders.GetMulti(null); // all orders will be read into the collection

' [VB.NET]

Dim orders As New OrderCollection()
orders.GetMulti(Nothing) ' all orders will be read into the collection

Review the help page for more details on loading data directly into collections.