Table of Contents

Class XmlAttributeReader

Namespace
LinqToDB.Metadata
Assembly
linq2db.dll

Metadata atributes provider. Uses XML document to describe attributes and their bindings.

public class XmlAttributeReader : IMetadataReader
Inheritance
XmlAttributeReader
Implements
Extension Methods

Examples

XML format:

<[Root]> <Type Name="<Type.FullName|Type.Name>"> <Member Name="<Name>"> [<Attribute />]* </Member> [<Attribute />]* </Type> </[Root]>

  1. Root node name could be any
  2. Type nodes define entity classes with entity type name specified in Name attribute (must be typeof(Entity).FullName or typeof(Entity).Name value)
  3. Member nodes define entity class members with mapping attributes with member name specified in Name attribute
  4. Attr nodes define attributes of entity (if nested into Type node) or entity member (when nested into Member node)

Attribute node format:

<[AttributeTypeName]> <[PropertyName] Value="<serialized_value>" Type="<Type.FullName|Type.Name>" /> </[AttributeTypeName]>

  1. Node name is a mapping attribute type name as Type.FullName, Type.Name or Type.Name without "Attribute" suffix
  2. PropertyName node name is a name of attribute property you want to set
  3. Type attribute specify value type as Type.FullName or Type.Name string and specified only for non-string properties
  4. Value contains attribute property value, serialized as string, understandable by ChangeType(object?, Type, MappingSchema?, ConversionType) method

Constructors

XmlAttributeReader(Stream)

Creates metadata provider instance.

public XmlAttributeReader(Stream xmlDocStream)

Parameters

xmlDocStream Stream

Stream with XML document.

XmlAttributeReader(string)

Creates metadata provider instance.

public XmlAttributeReader(string xmlFile)

Parameters

xmlFile string

Parameter could reference to (probed in specified order):

Resource search performed in calling assembly.

XmlAttributeReader(string, Assembly)

Creates metadata provider instance.

public XmlAttributeReader(string xmlFile, Assembly assembly)

Parameters

xmlFile string

Parameter could reference to (probed in specified order):

assembly Assembly

Assembly to load resource from for two last options from xmlFile parameter.

Methods

GetAttributes(Type)

Gets all mapping attributes on specified type.

public MappingAttribute[] GetAttributes(Type type)

Parameters

type Type

Attributes owner type.

Returns

MappingAttribute[]

Array of mapping attributes.

GetAttributes(Type, MemberInfo)

Gets all mapping attributes on specified type member.

public MappingAttribute[] GetAttributes(Type type, MemberInfo memberInfo)

Parameters

type Type

Member type. Could be used by some metadata providers to identify actual member owner type.

memberInfo MemberInfo

Type member for which mapping attributes should be returned.

Returns

MappingAttribute[]

Array of attributes.

GetDynamicColumns(Type)

Gets the dynamic columns defined on given type.

public MemberInfo[] GetDynamicColumns(Type type)

Parameters

type Type

The type.

Returns

MemberInfo[]

All dynamic columns defined on given type.

GetObjectID()

Should return a unique ID for cache purposes. If the implemented Metadata reader returns instance-specific data you'll need to calculate a unique value based on content. Otherwise just use a static const e.g. $".{nameof(YourMetadataReader)}."

public string GetObjectID()

Returns

string

The object ID as string