Class Schema
Describes a schema for data documents: TypedDocs and DynamicDocs.
DynamicDocs are "shaped" in memory from schema, whereas, TypedDocs define schema.
Schema for TypedDocs is cached in static dictionary for speed
Inheritance
System.Object
Schema
Implements
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Azos.dll
Syntax
[Serializable]
public sealed class Schema : INamed, IEnumerable<Schema.FieldDef>, IEnumerable, IJSONWritable
Constructors
Schema(String, Schema.FieldDef[])
Declaration
public Schema(string name, params Schema.FieldDef[] fieldDefs)
Parameters
Schema(String, Boolean, Schema.FieldDef[])
Declaration
public Schema(string name, bool readOnly, params Schema.FieldDef[] fieldDefs)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.Boolean |
readOnly |
|
Schema.FieldDef[] |
fieldDefs |
|
Schema(String, Boolean, IEnumerable<Schema.FieldDef>, IEnumerable<TableAttribute>)
Declaration
public Schema(string name, bool readOnly, IEnumerable<Schema.FieldDef> fieldDefs, IEnumerable<TableAttribute> tableAttributes = null)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.Boolean |
readOnly |
|
System.Collections.Generic.IEnumerable<Schema.FieldDef> |
fieldDefs |
|
System.Collections.Generic.IEnumerable<TableAttribute> |
tableAttributes |
|
Schema(String, Boolean, IEnumerable<TableAttribute>, Schema.FieldDef[])
Declaration
public Schema(string name, bool readOnly, IEnumerable<TableAttribute> tableAttributes, params Schema.FieldDef[] fieldDefs)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.Boolean |
readOnly |
|
System.Collections.Generic.IEnumerable<TableAttribute> |
tableAttributes |
|
Schema.FieldDef[] |
fieldDefs |
|
Fields
Declaration
public const string EXTRA_SUPPORTS_DELETE_ATTR = "supports-delete"
Field Value
Type |
Description |
System.String |
|
Declaration
public const string EXTRA_SUPPORTS_INSERT_ATTR = "supports-insert"
Field Value
Type |
Description |
System.String |
|
Declaration
public const string EXTRA_SUPPORTS_UPDATE_ATTR = "supports-update"
Field Value
Type |
Description |
System.String |
|
Properties
AnyTargetKeyFieldDefs
Returns FieldDefs in their order within rows that are declared as key fields in ANY_TARGET
Declaration
public IEnumerable<Schema.FieldDef> AnyTargetKeyFieldDefs { get; }
Property Value
AnyVisibleFieldDefs
Returns FieldDefs in their order within rows as
Declaration
public IEnumerable<Schema.FieldDef> AnyVisibleFieldDefs { get; }
Property Value
Returns Extra data that may be associated with schema by various providers.
The field is lazily allocated
Declaration
public JSONDataMap ExtraData { get; }
Property Value
FieldCount
Declaration
public int FieldCount { get; }
Property Value
Type |
Description |
System.Int32 |
|
FieldDefs
Returns FieldDefs in their order within rows that this schema describes
Declaration
public IEnumerable<Schema.FieldDef> FieldDefs { get; }
Property Value
Item[Int32]
Returns a field definition by a positional index within the row
Declaration
public Schema.FieldDef this[int index] { get; }
Parameters
Type |
Name |
Description |
System.Int32 |
index |
|
Property Value
Item[String]
Returns a field definition by a unique case-insensitive field name within schema
Declaration
public Schema.FieldDef this[string name] { get; }
Parameters
Type |
Name |
Description |
System.String |
name |
|
Property Value
Name
For TypedRows, returns a unique fully-qualified row type name, whichs is the global identifier of this schema instance
Declaration
public string Name { get; }
Property Value
Type |
Description |
System.String |
|
ReadOnly
Specifies that target that this schema represents (i.e. db table) is not updatable so DataStore will not be able to save row changes made in ram
Declaration
public bool ReadOnly { get; }
Property Value
Type |
Description |
System.Boolean |
|
SchemaEquivalenceEqualityComparer
Returns an instance of IEqualityComparer(Schema) that performs logical equivalence testing
Declaration
public static IEqualityComparer<Schema> SchemaEquivalenceEqualityComparer { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEqualityComparer<Schema> |
|
TableAttrs
Returns table-level attributes
Declaration
public IEnumerable<TableAttribute> TableAttrs { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEnumerable<TableAttribute> |
|
TypedDocType
Returns a type of TypedDoc if schema was created for TypedRow, or null
Declaration
public Type TypedDocType { get; }
Property Value
Type |
Description |
System.Type |
|
Methods
FromJSON(JSONDataMap, Boolean)
Declaration
public static Schema FromJSON(JSONDataMap map, bool readOnly = false)
Parameters
Type |
Name |
Description |
JSONDataMap |
map |
|
System.Boolean |
readOnly |
|
Returns
FromJSON(String, Boolean)
Declaration
public static Schema FromJSON(string json, bool readOnly = false)
Parameters
Type |
Name |
Description |
System.String |
json |
|
System.Boolean |
readOnly |
|
Returns
GetEnumerator()
Declaration
public IEnumerator<Schema.FieldDef> GetEnumerator()
Returns
GetFieldDefByBackendName(String, String, Func<Schema.FieldDef, FieldAttribute, Boolean>)
Returns FieldDef by BackendName for TargetName
Declaration
public Schema.FieldDef GetFieldDefByBackendName(string targetName, string backendName, Func<Schema.FieldDef, FieldAttribute, bool> func = null)
Parameters
Returns
GetFieldDefByIndex(Int32)
Finds fielddef by name or throws if name is not found
Declaration
public Schema.FieldDef GetFieldDefByIndex(int index)
Parameters
Type |
Name |
Description |
System.Int32 |
index |
|
Returns
GetFieldDefByName(String)
Finds fielddef by name or throws if name is not found
Declaration
public Schema.FieldDef GetFieldDefByName(string fieldName)
Parameters
Type |
Name |
Description |
System.String |
fieldName |
|
Returns
GetFieldMembers(Type)
Gets all property members of TypedDoc that are tagged as [Field]
Declaration
public static IEnumerable<PropertyInfo> GetFieldMembers(Type type)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo> |
|
GetForTypedDoc(TypedDoc)
Returns schema instance for the TypedDoc instance by fetching schema object from cache or
creating it if it has not been cached yet
Declaration
public static Schema GetForTypedDoc(TypedDoc doc)
Parameters
Returns
GetForTypedDoc(Type)
Returns schema instance for the TypedRow instance by fetching schema object from cache or
creating it if it has not been cached yet
Declaration
public static Schema GetForTypedDoc(Type tdoc)
Parameters
Type |
Name |
Description |
System.Type |
tdoc |
|
Returns
GetForTypedDoc<TDoc>()
Returns schema instance for the TypedRow instance by fetching schema object from cache or
creating it if it has not been cached yet
Declaration
public static Schema GetForTypedDoc<TDoc>()
where TDoc : TypedDoc
Returns
Type Parameters
GetKeyFieldDefsForTarget(String)
Returns FieldDefs in their order within rows that are declared as key fields for particular target
Declaration
public IEnumerable<Schema.FieldDef> GetKeyFieldDefsForTarget(string targetName)
Parameters
Type |
Name |
Description |
System.String |
targetName |
|
Returns
GetTableAttrForTarget(String)
Returns a TableAttribute that matches the supplied targetName, or if one was not defined then
returns TableAttribute which matches any target or null
Declaration
public TableAttribute GetTableAttrForTarget(string targetName)
Parameters
Type |
Name |
Description |
System.String |
targetName |
|
Returns
IsEquivalentTo(Schema, Boolean)
Performs logical equivalence testing of two schemas
Declaration
public bool IsEquivalentTo(Schema other, bool compareNames = true)
Parameters
Type |
Name |
Description |
Schema |
other |
|
System.Boolean |
compareNames |
|
Returns
Type |
Description |
System.Boolean |
|
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
TryFindFieldByTargetedBackendName(String, String, StringComparison)
Returns a field def that matches the desired backed name for the specified target or null
Declaration
public Schema.FieldDef TryFindFieldByTargetedBackendName(string targetName, string backendName, StringComparison backendNameComparison = StringComparison.OrdinalIgnoreCase)
Parameters
Type |
Name |
Description |
System.String |
targetName |
Target or null, if null any target assumed
|
System.String |
backendName |
The name of the backend
|
System.StringComparison |
backendNameComparison |
The string comparison to use against the backend name, OrdinalIgnoreCase is dflt
|
Returns
WriteAsJSON(TextWriter, Int32, JSONWritingOptions)
Writes schema as JSON. Do not call this method directly, instead call rowset.ToJSON() or use JSONWriter class
Declaration
public void WriteAsJSON(TextWriter wri, int nestingLevel, JSONWritingOptions options = null)
Parameters
Type |
Name |
Description |
System.IO.TextWriter |
wri |
|
System.Int32 |
nestingLevel |
|
JSONWritingOptions |
options |
|
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type |
Description |
System.Collections.IEnumerator |
|
Implements
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Extension Methods