Irwsoft Data Framework

View Data-schema
Brief Information
EditionsProfessional and Ultimate
ProvidersSqlClient, MySql and Oracle.
TopicsView data-schema class.

This sample will show how to design dataschema class for a view in database using Irwsoft Data Framework.
What you will learn :

  1. Irwsoft.Data.ViewAttribute marks a class as view data-schema.

  2. Irwsoft.Data.Column and Irwsoft.Data.ColumnAttribute :

    • Irwsoft.Data.Column represents as a column of the view.
    • Irwsoft.Data.ColumnAttribute used to marks a field as a column of the view data-schema.

Example : We have PersonView view with structure like this :

  • PersonID (int, PK)
  • FirstName (string)
  • Status (boolean) - represents available status of a person.
  • LeaderID (int, FK)
C# code
// 1) Must using ViewAttribute to describe view class
[View("PersonView")]
public class PersonView
{
     // 2) Must declare all columns needed with private modifier and ColumnAttribute on it.
     //    NOTE : For read-only column set ReadOnly to true and string column should specify its size.

     [Column("PersonId"DbType.Int32, true, PrimaryKey = true)]
     private Column _personId;

     [Column("FirstName"DbType.String, false)]
     private Column _firstName;

     [Column("Status"DbType.Boolean, false)]
     private Column _status;

     [Column("LeaderId"DbType.Int32, false)]
     private Column _leaderId;

     // 3) Declare public get accessor to read the data.
     //    NOTE : you must not provide set/write accessor since it will initialized by calling
     //           Irwsoft.Data.DataFactories.InitTableSchema

     public Column PersonId { get { return _personId; } }
     public Column FirstName { get { return _firstName; } }
     // ... other properties here

     // 4) Must have parameterless constructors, that call Irwsoft.Data.DataFactories.InitViewSchema

     public PersonView()
     {
          Irwsoft.Data.DataFactories.InitViewSchema(this);
     }
}

IDF supports DML query to View like DML query to table. For available DML syntax supported by IDF, please see Table Query.


Related Topics :

Irwsoft Data Ultimate Edition provides comprehensive features of Irwsoft Data Framework and support from irwsoft.