Created Model Base Class
Created the base class for all models and started on attributes
This commit is contained in:
7
Articulate/Articulate.csproj
Normal file
7
Articulate/Articulate.csproj
Normal file
@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
11
Articulate/Attributes/Column.cs
Normal file
11
Articulate/Attributes/Column.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
44
Articulate/DBConnection.cs
Normal file
44
Articulate/DBConnection.cs
Normal 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
28
Articulate/Model.cs
Normal 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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user