Search code examples
linq-to-sqlmetadataplinqo

What's a strategy for accessing Plinqo metadata from an external program?


I am using Plinqo and Linq-to-SQL to implement a repository. I'd like to inform the UI of validation rules by examining metadata and acting accordingly. Problem is, the Metadata classes in Plinqo are marked internal and are nested inside the classes they decorate.

How can I get at these classes and enumerate their attributes from another assembly?


Solution

  • The only way that I'm aware of accomplishing this is to use Reflection. The following code uses reflection and looks for all of the rule's attributes defined on the internal metadata class. DynamicData also does a similar lookup of the attributes defined in the Metadata class by using an attribute defined on the class that can be found in the generated partial class:

    [System.ComponentModel.DataAnnotations.MetadataType(typeof(PetShop.Data.Category.Metadata))]

    Thanks -Blake Niemyjski