Crudity 1.2.0

dotnet add package Crudity --version 1.2.0
NuGet\Install-Package Crudity -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Crudity" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Crudity --version 1.2.0
#r "nuget: Crudity, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Crudity as a Cake Addin
#addin nuget:?package=Crudity&version=1.2.0

// Install Crudity as a Cake Tool
#tool nuget:?package=Crudity&version=1.2.0

CRUDIgniter

CRUDIgniter helps developer to create a less CRUD operations using MySql database, it is very easy to use and makes your code more readable also lessen the codes in your Data Access Layer

Dependencies

MySql Connector .Net 6.9.9/MySql.Data https://downloads.mysql.com/archives/get/file/mysql-connector-net-6.9.9.msi

Installation

Via NuGet Package Manager (Console)

  1. Create new project.
  2. Save project.
  3. Go to Tools->Nuget Package Manager->Package Manager Console.
  4. Enter the command: Install-Package CrudIgniter then press enter.
  5. It will install the latest version and your done.

Via NuGet Package Manager (GUI)

  1. Create new project.
  2. Save project.
  3. Go to Tools->NuGet Package Manager->Manage NuGet Packager for Solution...
  4. Search for CrudIgniter then click Install
  5. If you see green check on beside the package then you successfully installed it.
  6. It will install the latest version and your done.

Example

Table

CREATE TABLE  `employee` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(45) NOT NULL,
  `Address` varchar(45) NOT NULL,
  `Email` varchar(45) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

C# Example

Model
namespace Models 
{
  public class Employee 
  {
    #region Constructor
    public Employee() {}
    
    public Employee(int id, string name, strin address, string email) 
    {
      this.Id = id;
      this.Name = name;
      this.Address = address;
      this.Email = email;
    }
     public Employee(string name, strin address, string email) 
    {
      this.Name = name;
      this.Address = address;
      this.Email = email;
    }
    #endregion

    #region Property
    public int Id { get;set; }
    public string Name { get;set; }
    public string Address { get;set; }
    public string Email { get;set; }
    #endregion
  }
}
Data Access Layer
using System.Data;
using CrudIgniter.Helper;

namespace DAL 
{
  private CRUD crud = new CRUD("change your connection string here..");
  
  // Get all employee
  public DataTable GetAllEmployee()
  {
    return crud.Select("employee");
  }
  
  // Get employee using id
  public DataTable GetEmployeeById(int id)
  {
    string sql = "SELECT * FROM employee WHERE Id=?";
    
    return crud.GetData(sql, new object[] {id});
  }
  
  // Insert employee record
  public void Create(Models.Employee employeeModel)
  {
    crud.Table = "employee";
    crud.Columns = new string[] { "Name", "Address", "Email" };
    crud.Values = new object[] { employeeModel.Name, employeeModel.Address, employeeModel.Email };
    crud.Insert();
  }
  
  // Update employee record
  public void Update(Models.Employee employeeModel)
  {
    crud.Table = "employee";
    crud.Columns = new string[] { "Name", "Address", "Email" };
    crud.Values = new object[] { employeeModel.Name, employeeModel.Address, employeeModel.Email };
    crud.Where = new string[] { "Id" };
    crud.Where = new object[] { employeeModel.Id };
    crud.Update();
  }
  
  // Delete employee record
  public void Delete(int id)
  {
    crud.Table = "employee";
    crud.Where = new string[] { "Id" };
    crud.Where = new object[] { id};
    crud.Delete();
  }
}
Business Logic Layer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using CrudIgniter.Helper;

namespace BLL
{
  private DAL.Employee employeeDAL = new DAL.Employee();
  
  // Convert datatable to list of object 'Employee'
  public List<Models.Employee> GetAllEmployee() 
  {
    return employeeDAL.GetAllEmployee().ToList<Models.Employee>();
  }
  
  // Convert datarow to object
  public Models.Employee GetEmployeeById(int id)
  {
    Models.Employee employeeModel = new Models.Employee();
    
    foreach (DataRow row in employeeDAL.GetEmployeeById(id).Rows)
    {
      employeeModel = row.ToObject<Models.Employee>();
    }
    
    return employeeModel;
  }
  
  public void Create(Models.Employee employeeModel)
  {
    // You can add validation here
  
    employeeDAL.Create(employeeModel);
  }
  
  public void Update(Models.Employee employeeModel)
  {
    // You can add validation here
    
    employeeDAL.Update(employeeModel);
  }
  
  public void Delete(int id)
  {
    employeeDAL.Delete(id);
  }
}
UI/Console
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyApp
{
  class Program
  {
        static void Main(string[] args)
        {

            BLL.Employee employeeBLL = new BLL.Employee();

            // Get all employee
            foreach (Models.Employee employeeModel in employeeBLL.GetAllEmployee())
            {
                Console.WriteLine("___________________________________");
                Console.WriteLine("ID: " + employeeModel.Id);
                Console.WriteLine("Name: " + employeeModel.Name);
                Console.WriteLine("Address: " + employeeModel.Address);
                Console.WriteLine("Email: " + employeeModel.Email);
                Console.WriteLine("___________________________________\n");
            }

            Console.ReadKey();
        }
  }
}
Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 616 3/23/2019
1.0.0 563 3/23/2019