DEV Community

lith wang
lith wang

Posted on • Updated on

Introducing Vitorm: The Perfect Balance of Simplicity and Power in ORM for NetCore

Are you tired of choosing between simplicity and functionality when it comes to Object-Relational Mappers (ORMs)? Meet Vitorm, the lightweight yet comprehensive ORM designed to offer you the best of both worlds.

source address: https://github.com/Vit-Orm/Vitorm

What is Vitorm?

Vitorm is a lightweight ORM that strikes the perfect balance between simplicity and functionality. It’s inspired by the minimalist design of Dapper, offering an easy-to-use and efficient interface for data access. But Vitorm doesn’t stop there. It goes beyond the basic capabilities of lightweight ORMs to provide a rich feature set comparable to Entity Framework.

Why Choose Vitorm?

  • Simplicity and Efficiency: With a design reminiscent of Dapper, Vitorm ensures you can quickly and efficiently perform data access tasks without the overhead of complex configurations.
  • Robust Features: Similar to Entity Framework, Vitorm offers a comprehensive set of features, including advanced querying, relationship mapping, and change tracking.
  • Performance: Get the high performance and speed you expect from a lightweight ORM while still enjoying the advanced capabilities typically found in more heavyweight solutions.

Key Features

  • Easy-to-Use Interface: Intuitive and straightforward, making it accessible for developers of all skill levels.
  • Advanced Querying: Supports complex queries, ensuring you can handle any data access scenario.
  • Relationship Mapping: Easily manage relationships between entities, just like you would with more feature-rich ORMs.

Who Should Use Vitorm?

Vitorm is ideal for developers who want the performance and simplicity of Dapper but need the robust features and flexibility of Entity Framework. Whether you’re building a small project or a large-scale application, Vitorm provides a powerful yet streamlined solution that can adapt to your needs.


Join the conversation and start exploring what Vitorm can do for your next project. Happy coding!

Comparison of performance with other ORMs

Through benchmarks, there may be slight variations depending on the database source, for reference only.
code address: Vitorm.Data.Benchmark

SqlServer

Method queryJoin take runner Mean Error StdDev
Run False 1 EntityFramework 5.380 ms 0.0449 ms 0.0398 ms
Run False 1 SqlSuger 4.929 ms 0.0588 ms 0.0550 ms
Run False 1 Vitorm 4.925 ms 0.0506 ms 0.0474 ms
Run False 1000 EntityFramework 6.009 ms 0.0963 ms 0.0853 ms
Run False 1000 SqlSuger 5.616 ms 0.1114 ms 0.1488 ms
Run False 1000 Vitorm 5.539 ms 0.1060 ms 0.1262 ms
Run True 1 EntityFramework 5.453 ms 0.0571 ms 0.0534 ms
Run True 1 SqlSuger 5.601 ms 0.0477 ms 0.0423 ms
Run True 1 Vitorm 5.337 ms 0.0596 ms 0.0528 ms
Run True 1000 EntityFramework 1,706.222 ms 4.4435 ms 3.9391 ms
Run True 1000 SqlSuger 125.150 ms 2.3678 ms 2.3255 ms
Run True 1000 Vitorm 21.027 ms 0.3564 ms 0.3334 ms

MySql

Method queryJoin take runner Mean Error StdDev
Run False 1 EntityFramework 1,231.1 μs 47.43 μs 139.84 μs
Run False 1 SqlSuger 873.7 μs 22.33 μs 65.49 μs
Run False 1 Vitorm 636.7 μs 21.15 μs 62.37 μs
Run False 1000 EntityFramework 4,764.8 μs 56.52 μs 52.87 μs
Run False 1000 SqlSuger 1,906.4 μs 33.21 μs 42.00 μs
Run False 1000 Vitorm 2,159.5 μs 43.16 μs 56.12 μs
Run True 1 EntityFramework 1,775.0 μs 35.01 μs 80.45 μs
Run True 1 SqlSuger 1,747.5 μs 34.05 μs 44.27 μs
Run True 1 Vitorm 1,292.5 μs 25.72 μs 41.54 μs
Run True 1000 EntityFramework 6,784.4 μs 102.05 μs 95.45 μs
Run True 1000 SqlSuger 113,634.4 μs 1,128.58 μs 1,055.67 μs
Run True 1000 Vitorm 3,175.2 μs 62.02 μs 88.95 μs

Sqlite

Method queryJoin take runner Mean Error StdDev
Run False 1 EntityFramework 115.32 μs 0.831 μs 0.778 μs
Run False 1 SqlSuger 81.66 μs 0.747 μs 0.699 μs
Run False 1 Vitorm 45.64 μs 0.350 μs 0.328 μs
Run False 1000 EntityFramework 1,386.81 μs 13.684 μs 12.800 μs
Run False 1000 SqlSuger 674.82 μs 4.938 μs 4.619 μs
Run False 1000 Vitorm 769.88 μs 6.020 μs 5.631 μs
Run True 1 EntityFramework 220.27 μs 1.916 μs 1.793 μs
Run True 1 SqlSuger 484.52 μs 6.746 μs 5.980 μs
Run True 1 Vitorm 167.89 μs 1.352 μs 1.264 μs
Run True 1000 EntityFramework 1,962.25 μs 10.031 μs 8.377 μs
Run True 1000 SqlSuger 103,179.50 μs 534.265 μs 446.135 μs
Run True 1000 Vitorm 1,684.39 μs 21.895 μs 18.283 μs

Examples

Let's walk through the steps to set up and use Vitorm with SQLite.

Installation

Before using Vitorm, install the necessary package:

dotnet add package Vitorm.Sqlite
Enter fullscreen mode Exit fullscreen mode

Minimum viable demo

code address: Program_Min.cs

using Vitorm;
namespace App
{
    public class Program_Min
    {
        static void Main2(string[] args)
        {
            // #1 Init
            using var dbContext = new Vitorm.Sql.SqlDbContext();
            dbContext.UseSqlite("data source=sqlite.db");

            // #2 Query
            var user = dbContext.Get<User>(1);
            var users = dbContext.Query<User>().Where(u => u.name.Contains("li")).ToList();
        }

        // Entity Definition
        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
        public class User
        {
            [System.ComponentModel.DataAnnotations.Key]
            public int id { get; set; }
            public string name { get; set; }
            public DateTime? birth { get; set; }
            public int? fatherId { get; set; }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

For full example please check here: Program.cs

Vitorm.Data Documentation

Vitorm.Data is a static class that allows you to use Vitorm without explicitly creating or disposing of a DbContext.

Installation

Before using Vitorm.Data, install the necessary package:

dotnet add package Vitorm.Data
dotnet add package Vitorm.Sqlite
Enter fullscreen mode Exit fullscreen mode

Config settings

// appsettings.json
{
  "Vitorm": {
    "Data": [
      {
        "provider": "Sqlite",
        "namespace": "App",
        "connectionString": "data source=sqlite.db;"
      }
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

Minimum viable demo

After configuring the appsettings.json file, you can directly perform queries without any additional configuration or initialization, Vitorm.Data is that easy to use.

code address: Program_Min.cs

using Vitorm;
namespace App
{
    public class Program_Min
    {
        static void Main2(string[] args)
        {
            //  Query Records
            var user = Data.Get<User>(1);
            var users = Data.Query<User>().Where(u => u.name.Contains("li")).ToList();
        }

        // Entity Definition
        [System.ComponentModel.DataAnnotations.Schema.Table("User")]
        public class User
        {
            [System.ComponentModel.DataAnnotations.Key]
            public int id { get; set; }
            public string name { get; set; }
            public DateTime? birth { get; set; }
            public int? fatherId { get; set; }
        }
    }
}

Enter fullscreen mode Exit fullscreen mode

For full example please check here: Program.cs

Top comments (1)

Collapse
 
lithwang profile image
lith wang

Any questions or ideal or new feature wanted, please feel free to talk.