Skip to content

Create SQL Table

Imran J edited this page Dec 22, 2018 · 2 revisions

Location

All SQL tables are located in the database folder and separated by the group of data they represent.

How to create a new table

To create a new table you must create a new class and tag it by TableName attribute.

All column are represented by public properties and variables, if you set a property or variable private or protected, it won't be generated by the ORM and you won't be able retrieve data from database with those ones.

You can also add others attributes like :

  1. PrimaryKey : To set a column as primary key in the table. (above a property/variable)
  2. NullString : To allow a column to be null. (above a property/variable)
  3. Index : To set an index on a colmun. (above a property/variable)
  4. TableName : To indicate that the class is a SQL Table structure. (above a class) between the parenthesis, it's the tablename of the database.

Example

[TableName("accounts")]
public class AccountRecord : IAutoGeneratedRecord
{
    [PrimaryKey("Id")]
    public int Id { get; set; }
    [NullString]
    public string Username { get; set; }
    [Index]
    public byte Authority { get; set; }
    public string Password { get; set; }
    public string HDSN { get; set; }
    public string IP_Key { get; set; }
}

Clone this wiki locally