Skip to content

Simple ORM for C# possibiliting connect to MySql, Sql Server, MariaDB databases.

Notifications You must be signed in to change notification settings

ConvORM/Conv.ORM.NET5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Conv.ORM - NET 5.0

Simple ORM for C# possibiliting connect to MySql, Sql Server, MariaDB, Firebird, Postgree databases.

GitHub language count Repository size GitHub last commit Stargazers

⚠ Still in Development 🚧⚙🔧🖥

Table of contents

💻 About the project

Conv.ORM is a simple ORM, designed to remove the need for a developer to deal with SQL commands, thus speeding up the development process and facilitating maintenance.

🚧 It works?

Yes, but not quite. Currently the following features are functional:

  • MySql/MariaDB and MSSQL connection;
  • Insert, Update and Search entities for DB mentioned above;

🛤 RoadMap

The full roadmap can be found in full here

  • Delete entities;
  • Inactivation entities;
  • Full select commands;
  • Full conditions for querys commands;
  • Allow relationship between entities;
  • Temporary entities;
  • Read-only entities;
  • Allow to custom events before and after executions;
  • Support for Postgree;
  • Support for Firebird;
  • Support for SQLite;

🧭 Firsts Steps

Before you start, you will need to install it on your project:

Using dotnet cli

$ dotnet add package Conv.ORM

Using Nuget Package Manager

PM> Install-Package Conv.ORM

⬇ Implements in your app

  1. Create a connection:
  • Using connection file:
Connection connection = ConnectionFactory.GetConnection();
  • Using specified parameters
ConnectionParameters connectionParameters = new ConnectionParameters("Default", EConnectionDriverTypes.ecdtMySql, "127.0.0.1", "3306", "databaseTest", "root", "123456");
Connection connection = ConnectionFactory.GetConnection(connectionParameters);
  1. Create a entity
[EntitiesAttributes(TableName = "User")]
public class UserEntity : Entity
{
     [EntitiesColumnAttributes(
         Primary = true,
         Default = "0"
     )]
     public int UserId;
     public string Name;
     public string Login;
     public string Password;
     [EntitiesColumnAttributes(Default = "true")]
     public bool Active;
}
  1. Create a manipulations methods
  • Save
public UserEntity Save()
{
    var userRepository = new Repository();
    try
    {
        if (UserId != 0)
            return (UserEntity)userRepository.Update(this);
        else
            return (UserEntity)userRepository.Insert(this);
    }
    catch(Exception ex)
    {
        Console.Write(ex.Message);
        throw;
     }
}
  • Find All
public IList FindAll()
{
    var userRepository = new Repository();
    try
    {
        return userRepository.FindAll(this);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
        throw;
    }
}
  • Find by conditions
public IList Find(QueryConditionsBuilder conditionsBuilder)
{
    var userRepository = new Repository();
    try
    {
        return userRepository.Find(this, conditionsBuilder);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
        throw;
    }
}
  • Find by id
public UserEntity Find(int id)
{
    var userRepository = new Repository();
    try
    {
        return (UserEntity)userRepository.Find(this, new int[] {id});
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex);
        throw;
    }
}
  1. Searching
  • For conditions to find registers, you can create a ConditionBuilder:
var queryConditions = new QueryConditionsBuilder();
queryConditions.AddQueryCondition("name", EConditionTypes.Like, new object[] {"%" + txtTextToSearch.Text + "%"});
queryConditions.AddQueryCondition("active", EConditionTypes.Equals, new object[] { rbOnlyActives.Checked ? 1 : 0 });

dgvRegisters.DataSource = ConvORMHelper.ConvertListToDataTable(userEntity.Find(queryConditions));
  1. 📚 For full documentation, go to here (In development)

Made with ❤ and ☕ by Luís Guilherme N. Maruccio - 👋 Contact me!