Proper Use of DataObjectField

Proper Use of DataObjectField

Old forum URL: forums.lhotka.net/forums/t/4322.aspx


Inquistive_Mind posted on Friday, February 08, 2008

Hello,

         I have used the parameters of DataObjectField() to specify the property of  BO.I did not have issues until I came across a situation where in I did not have a single property which could act as the primary key value for the object since it refered to a table with a composite key.

How can I handle this case?Or is it even required because I have other objects without the DataObjectField parameters.However I do have the GetIdValue() override as below.

protected override object GetIdValue()

{

            return string.Format( "{0}:{1}",_assetID.ToString(),_fuel.ToString());

}

 

When and where will the DataObjectField() parameters come into play?I have gone through Chapter 5 page 317 of 2005 where theres an explanation but cant seem to picture :(.Any more information would be of great help.

Thanks in Advance

Vikas

praevsky replied on Friday, February 08, 2008

Sooner or later, everyone puts an auto-increment primary key named ID in the first field of every table.  Sometimes I get wild and crazy and call it xxxID, where the table is xxx.  No matter what the field name is, I call the Business Class property ID.  But that's just me.  Every time I forget to do this, it comes back to bite me. 

Inquistive_Mind replied on Tuesday, February 12, 2008

Thanks for your reply but we do have tables with composite keys and when we build list objects out of them, we have the DataObjectField(false,false,false) since none of the properties of the BO do not uniquely identify the item in the collection.

Vikas

JohnB replied on Friday, February 08, 2008

I haven't come across this just yet but I think what you have in place will work just fine.

Copyright (c) Marimer LLC