| Milos How-To |
| Creating Business Entities with non-Guid Primary Keys |
The first example shows the integer version:
public class EmployeeEntity : BusinessEntity { public EmployeeEntity() : base() {} public EmployeeEntity(int id) : base(id) {} // ... the rest of the class continues on as usual.
A string-based entity is created in a very similar fashion:
public class EmployeeEntity : BusinessEntity { public EmployeeEntity() : base() {} public EmployeeEntity(string id) : base(id) {} // ... the rest of the class continues on as usual.
Also, entities that are based on string or integer primary keys, we need to use different properties to query the keys. Here's the integer version:
int intKey = oEnt.PKInteger;
And the string version:
string strKey = oEnt.PKString;
Asides from these differences, simple entities behave exactly the same way, no matter what keys the are based on. Most of the differences are absorbed by the business object (see also: Creating a Simple Business Object).
However, there are additional considerations for entities that manage related child records. For more information, see Creating a Collection of Child Objects.