Using AttributesMetadataSource
This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.
This topic is focused on MetadataContainer generation from CLR Attributes. Telerik Data Access defines AttributesMetadataSource to help generating MetadataContainer. An additional condition when you use the AttributesMetadataSource is the mapping to be done via CLR attributes ( the Mapping Type option in the Advanced Options Page of the Telerik Data Access Create Model Wizard is set to Attributes).
The AttributesMetadataSource class, exposes two static factory methods allowing you to create a new AttributesMetadataSource instance from different objects. When you have an instance of the AttributesMetadataSource class, you have to invoke the GetModel method to access the loaded metadata container.
-
FromAssembly - constructs a metadata container from an assembly containing persistent classes.
Telerik.OpenAccess.Metadata.AttributesMetadataSource attributesMetadataSource = Telerik.OpenAccess.Metadata.AttributesMetadataSource .FromAssembly(Assembly.GetExecutingAssembly()); Telerik.OpenAccess.Metadata.MetadataContainer metadataContainer = attributesMetadataSource.GetModel();
Dim attributesMetadataSource As Telerik.OpenAccess.Metadata.AttributesMetadataSource = _ Telerik.OpenAccess.Metadata.AttributesMetadataSource _ .FromAssembly(System.Reflection.Assembly.GetExecutingAssembly()) Dim metadataContainer As Telerik.OpenAccess.Metadata.MetadataContainer = _ attributesMetadataSource.GetModel()
-
FromContext - constructs a metadata container from an existing OpenAccessContext.
Telerik.OpenAccess.Metadata.AttributesMetadataSource attributesMetadataSource = Telerik.OpenAccess.Metadata.AttributesMetadataSource .FromContext(typeof(EntitiesModel)); Telerik.OpenAccess.Metadata.MetadataContainer metadataContainer = attributesMetadataSource.GetModel();
Dim attributesMetadataSource As Telerik.OpenAccess.Metadata.AttributesMetadataSource = _ Telerik.OpenAccess.Metadata.AttributesMetadataSource _ .FromContext(GetType(EntitiesModel)) Dim metadataContainer As Telerik.OpenAccess.Metadata.MetadataContainer = _ attributesMetadataSource.GetModel()