Show / Hide Table of Contents

    Interface IDataObject

    Data object interface

    Namespace: XData
    Assembly: XData.docfx.dll
    Syntax
    [JsonConverter(typeof(JsonDataObjectConverter<IDataObject>))]
    public interface IDataObject : ISqlObject
    Remarks

    Mapping domain object to database

    WARNING! Data object mapping requires DataObjectAttribute!

    Hint: Use DataTableAttribute, SubqueryAttribute and InnerViewAttribute to map data object to data sources

    Hint: Use FilterAttribute's specific successor to link data sources and apply filters to data

    Hint: Use ExternalLinkAttribute to declare master/slave relations between repositories

    Hint: Use Lob to map binary fields

    [Property("scan", "SC", Flags = DataPropertyFlag.OuterFlag)]

    public Lob Scan { get; set; }

    Hint: Use Xml to map Xml fields

    [Property("source", "SR", Flags = DataPropertyFlag.OuterFlag)]

    public Xml Source { get; set; }

    Hint: Use Link<TVal, TSrc> to map data link

    [Property("name", "S"),

    DictionaryProperty("Name", "DocState"),

    DictionaryProperty("Code", "DocStateCode")]

    public Link<string, DocState> DocState { get; set; }

    Hint: Use ColumnAttribute to map data without declaring property (for example to declare Id)

    [DataObject("S"),

    DataTable("T_DOC_STATE", "S"),

    Column("DocStateId", "doc_state_id", typeof(long?), "S", Flags = DataPropertyFlag.Id)]

    Hint: Use PropertyExpressionAttribute or ColumnExpressionAttribute to use SQL expression or subquery as property (or mapped column) data source

    [Property("doc_amount"),

    PropertyExpression("A", DataExpressionType.SubQuery, DbType.Decimal, ExprSize = 17, ExprScale = 5)]

    public double? DocAmount { get { return this.GetProperty(() => DocAmount); } }

    Hint: Use PropertyDefaultAttribute or ColumnDefaultAttribute to set default value generation rule to property (or mapped column)

    [Property("doc_date", "D"),

    PropertyDefault(DefaultType.CurrentDate)]

    public DateTime? DocDate { get; set; }

    Hint: Use ReferenceAttribute to use inner view property in parent data object

    [PropertyLink("HistoryDate", "H")]

    public DateTime? DocLastChange { get { return this.GetProperty(() => DocLastChange); } }

    Hint: Declare readonly fields as

    [PropertyLink("HistoryDate", "H")]

    public DateTime? DocLastChange { get { return this.GetProperty(() => DocLastChange); } }

    Hint: Declare custom logic functions (see IDataLogic<T> and Execute<T>(ICollection<T>, String, IDictionary<String, Action<Byte[]>>, IDictionary<String, Func<Byte[], Byte[]>>)) as

    //generate unique action key and use it for mark it realization in IDataLogic<Invoice>

    [CustomAction("{ab12d6f0-69d0-4997-bb0b-5f5f7c0581d1}")]

    public static CustomLogic<Invoice> TestCustomLogic;

    //using

    obj.Execute(() => Invoice.TestCustomLogic);

    Hint: Variables can be used as temporary values storage

    // store

    obj.GetRepository().Variables.Add("SomeName", "SomeValue");

    // and somewhere you can get it

    var something = obj.GetRepository().Variables["SomeName"];

    Hint: HierarchyAttribute can be used to fill and maintain hierarchy tables automatically

    // Table T_TEST has parent_id field tree linked to test_id (T_TEST's pk)

    // Table L_TEST has two fields parent_id and child_id all linked to T_TEST.test_id

    // Table L_TEST contains all subtree relations inside T_TEST

    // For example: for T_TEST (test_id, parent_id): (1, null) : (2, 1) : (3, 2)

    // L_TEST will contain (parent_id, child_id): (1, 1) : (1, 2) : (1, 3) : (2, 2) : (2, 3) : (3, 3)

    [DataObject("T"),

    DataTable("T_TEST", "T"),

    Hierarchy("T", "L_TEST", "parent_id", "parent_id", "child_id"),

    Column("TestId", "test_id", typeof(long?), "T", Flags = DataPropertyFlag.Id)]

    Examples

    [DataObject("T"),

    DataTable("T_DOC_TYPE", "T"),

    Column("DocTypeId", "doc_type_id", typeof(long?), "T", Flags = DataPropertyFlag.Id)]

    public class DocType : IDataObject {

    [Property("name", "T")]

    public string Name { get; set; }

    [Property("code", "T")]

    public string Code { get; set; }

    }

    Extension Methods

    DataObjectExtensions.Modify<T>(T, Action<T>[])
    DataObjectExtensions.GetProperties<T>(T, IEnumerable<String>, DataVersion)
    DataObjectExtensions.GetProperties<T>(T, String[])
    DataObjectExtensions.GetProperties<T>(T, DataVersion, String[])
    DataObjectExtensions.IsCleared<T>(T, String)
    DataObjectExtensions.IsChanged<T>(T, String)
    DataObjectExtensions.IsChanged<T>(T, Expression<Func<T, Object>>[])
    DataObjectExtensions.IsEmpty<T>(T, String)
    DataObjectExtensions.IsEmpty<T>(T, Expression<Func<T, Object>>)
    DataObjectExtensions.GetProperty<TRet>(IDataObject, String)
    DataObjectExtensions.GetContext(IDataObject)
    DataObjectExtensions.GetLayer(IDataObject)
    DataObjectExtensions.GetRepositoryAlias(IDataObject)
    DataObjectExtensions.IsAttached(IDataObject, Type)
    DataObjectExtensions.GetState<T>(T)
    DataObjectExtensions.CheckState<T>(T, DataObjectState)
    SerializationExtensions.ToXml<T>(T)
    CollectionsExtensions.SetValue<TKey, T>(TKey, T)
    CollectionsExtensions.AsEnum<T>(T)
    DataObjectQueryableExtensions.CompareVariable(Object, FilterOperation, String)
    Processing.Do<T>(T, Action<IProcess<T>>[])
    TypeExtensions.TryConvert<T, TResult>(T, Func<T, TResult>)
    TypeExtensions.TryConvert<T, TResult>(T, Func<T, TResult>, TResult)
    TypeExtensions.ChangeType<T>(Object)
    TypeExtensions.ChangeType(Object, Type)
    TypeExtensions.InvokeMethod<TRet>(Object, Type[], Expression<Func<TRet>>, BindingFlags)
    TypeExtensions.InvokeMethod(Object, Type[], Expression<Action>, BindingFlags)
    TypeExtensions.InvokeMethod<TRet>(Object, Expression<Func<TRet>>, BindingFlags)
    TypeExtensions.InvokeMethod(Object, Expression<Action>, BindingFlags)
    SqlBlockExtensions.SetExpression<TTag, TResult>(TTag, Expression<Func<IBlockQueryAdapter, TResult>>)
    QueryDescriptionExtensions.SetExpression<TTag, TResult>(TTag, Expression<Func<IQueryStructureAdapter, TResult>>)
    QueryDescriptionExtensions.GetProperty(ISqlObject, String)

    See Also

    IRepository<T>
    IDataLogic<T>
    CheckState<T>(T, DataObjectState)
    SetDeleted<T>(T, Boolean)
    Execute<T>(T, Expression<Func<CustomLogic<T>>>, IDictionary<String, Action<Byte[]>>, IDictionary<String, Func<Byte[], Byte[]>>)
    Serialize<T>(T)
    Restore<T>(T, SerializedData)
    GetProperties<T>(T, DataVersion, String[])
    GetProperty<T, TRet>(T, Expression<Func<T, TRet>>, DataVersion)
    XData.DataObjectExtensions.GetProperty``1(``0,System.String,XData.DataVersion)
    GetRepository<T>(T)
    IsChanged<T>(T, Expression<Func<T, Object>>[])
    IsEmpty<T>(T, Expression<Func<T, Object>>)
    IsCleared<T>(T, String)
    SetCurrent<T>(T)
    Submit<T>(T, DataSubmitFlag)
    Lock<T>(T)
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX