| Milos How-To |
| Using String Keys |
public class CustomerBO : BusinessObject { protected override void Configure() { this.MasterEntity = "Customers" ; this.PrimaryKeyField = "CustID" ; this.PrimaryKeyType = EPS.Data.KeyType.String; } }
This example assumes that the CustID field is a string field that is big enough to hold the string representation of a Guid. This may not always be the case though. Often, a string key may be an abritrary alphanumeric key generated by some type of algorithm, as in the following example:
public class CustomerBO : BusinessObject { protected override void Configure() { this.MasterEntity = "Customers" ; this.PrimaryKeyField = "CustID" ; this.PrimaryKeyType = EPS.Data.KeyType.String; } public override int GetNewStringKey(string EntityName, DataSet DataSetWithNewRecord) { return "NEWKEY" ; // Return a real value here, rather than "NEWKEY" } }
As in the integer example Using Non-Identity Integer Keys, this version would not work in a real-live application, since the value needs to be unique. Once again, a more sophisticated algorithm would be required.