Unfortunately the MetadataProvider is not designed for extension with partial classes. You should apply the changes directly in the class and make sure that it will not be overridden next time you regenerate the service. I would suggest you to rename the folder in which the file resides and thus next time you regenerate the service the default folder will be created again. This will result in compilation errors and to solve them you should just delete the newly created folder. The code which is in this folder is not dynamic, it is one and the same for each service generation so this should be safe operation.
About the changes you should apply:
1. You need to add additional metadata in OpenAccessMetadataProvider.AddPropertiesForResourceType()
method. You can see in the attached application how this is done by invoking the WebApplication1.oDataExtender.EnrichMetadata(resourceType, persistentType)
method. This will provision the new property to the service.
2. Now the problem is that the client doesn't know that this is a read only property and he/she could try to update it, to prevent it you should modify the OpenAccessUpdateProvider.SetValue()
method as well and check if this property is allowed for update. In the attached sample application this is done with the call: if (WebApplication1.oDataExtender.CanUpdate(targetResource, propertyName) == false) return;
You should know that the SetValue
method is called for each and every object and property
being updated so your implementation for the check it this is allowed update or not should be extremely fast and efficient.
Here is the sample code of the oDataExtender class:
EnrichMetadata(ResourceType resourceType, MetaPersistentType persistentType)
var propKind = ResourcePropertyKind.Primitive;
var resType = ResourceType.GetPrimitiveResourceType(
var prop =
, propKind, resType);
Please excuse me that the demo code is in C#, it is really simple and I hope you will not have any problems translating it to VB. Should you have any additional question do not hesitate to get back to us.
OpenAccess ORM is now Telerik Data Access
. For more information on the new names, please, check out the Telerik Product Map