Created Model Base Class

Created the base class for all models and started on attributes
This commit is contained in:
2021-07-30 07:58:07 +10:00
parent 057e593f28
commit 6cf59c41cc
4 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Articulate.Attributes
{
public class Column : Attribute
{
public string Type { get; set; }
}
}

View File

@ -0,0 +1,44 @@
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Text;
namespace Articulate
{
public class DBConnection
{
public string Server { get; set; }
public string DatabaseName { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
private MySqlConnection Connection { get; set; }
private static DBConnection _instance = null;
public static DBConnection Instance()
{
if (_instance == null)
_instance = new DBConnection();
return _instance;
}
public bool IsConnect()
{
if (Connection == null)
{
if (String.IsNullOrEmpty(DatabaseName))
return false;
string connstring = string.Format("Server={0}; database={1}; UID={2}; password={3}", Server, DatabaseName, UserName, Password);
Connection = new MySqlConnection(connstring);
Connection.Open();
}
return true;
}
public void Close()
{
Connection.Close();
}
}
}

28
Articulate/Model.cs Normal file
View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Articulate
{
public class Model
{
protected string Table = string.Empty;
protected string PrimaryKey = "id";
protected string KeyType = "integer";
protected bool Incrementing = true;
protected bool Timestamps = false;
public bool Insert()
{
return false;
}
public static void Get()
{
}
}
}