Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to add a complex index involving XPO service columns (GCRecord and ObjectType)

$
0
0

Scenario
This article demonstrates how to use the IndexedAttribute with the service XPO columns (ObjectType and GCRecord) to accomplish the following requirements:

1. Make persistent objects data unique against the class type;
2. Avoid data duplication with records that are already deleted, but are still physically present in the database due to the enabled deferred deletion.


Steps to implement
1. Decorate the required data property, which must be unique against the object type with the DevExpress.Xpo.Indexed attribute taking "ObjectType" and Unique = true as parameters.
2. Decorate the required data property, which must be unique without taking into account deleted records data with the DevExpress.Xpo.Indexed attribute taking "GCRecord" and Unique = true as parameters.
Check out the BasePersistentClass class in the BO.xx file and unit tests within the Program.xx file for more details.

IMPORTANT NOTES

1. Beware of MS Access limitation which lies in skipping NULL values when checking value uniqueness.
2. The IndexedAttribute/IndicesAttribute involving the service ObjectType and GCRecord columns can be used only in the base persistent class, because XPO creates these columns only in the base table. 
To add uniqueness on the service columns in the derived class, you should declare additional persistent clone-properties that will return the value of the corresponding source property. Refer to the 
Check out the DerivedPersistentClass class in the BO.xx file for more details.


See Also:
IndexedAttribute Class
IndicesAttribute Class
Table Indexes


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>