Telerik OpenAccess ORM delivers a generic API that allows access to the metadata of persistent classes based on .NET Component Model and without the use of Reflection. The advantage this functionality gives is the ability to perform operations with objects, without knowing the types, properties or attributes of those objects. It is also the API for using the artificial fields functionality of OpenAccess. Another advantage is gaining access to otherwise non-visible fields of a persistent class.
That means that using OpenAccess internal identity or versioning does not prevent the user from discovering their values for any specific persistence capable instance.
The entry point for using this API is the Telerik.OpenAccess.Metadata.PersistentMetaData class. It is accessible as a property of the IObjectScope. This means that the generic metadata access functionality is only available in connected scenarios.
IObjectScope.PersistentMetadata
The most significant method of IObjectScope.PersistentMetadata property is the GetPersistentTypeDescriptor(Type type) method. The method returns an IPersistentTypeDescriptor instance which implements the System.ComponentModel.ICustomTypeDescriptor.
C# |
Copy Code |
IObjectScope scope = Database.Get("DatabaseConnection1").GetObjectScope(); IPersistentTypeDescriptor ptd = scope.PersistentMetadata.GetPersistentTypeDescriptor(typeof(Person)); |
VB .NET |
Copy Code |
Dim scope As IObjectScope = Database.Get("DatabaseConnection1").GetObjectScope() Dim ptd As IPersistentTypeDescriptor = scope.PersistentMetadata.GetPersistentTypeDescriptor(GetType(Person)) |
Another useful method is the GetPersistentTypeNames() which returns all the names of the persistent types associated with the calling object scope.