Forem

Oleksandr Viktor
Oleksandr Viktor

Posted on

UkrGuru.Sql: Minimal Effort, Maximum Results!

Hey everyone, check out the new open-source UkrGuru.Sql package! It's a powerful library designed to simplify interactions between .NET applications and SQL Server databases.

Key Features

  • Ease of Use: Simplifies database operations with minimal code.
  • Flexibility: Supports various SQL operations and data types.
  • Performance: Optimized for efficient database interactions.

Example Usage

Here's a quick example to demonstrate how easy it is to use UkrGuru.Sql:

using UkrGuru.Sql;

// Set the connection string
DbHelper.ConnectionString = "Server=(localdb)\\mssqllocaldb";

// Execute a simple query
var result = DbHelper.Exec<int>("SELECT @A + @B", new { A = 2, B = 2 });
Console.WriteLine($"Result: {result}");

// Work with JSON data
var person = new { Id = 1, Name = "John" };
var json = DbHelper.Exec<string>("SELECT @Data", person.ToJson());
Console.WriteLine($"Result: {json}");

// Read multiple records
var persons = DbHelper.Read<Person>("SELECT 1 Id, 'John' Name UNION ALL SELECT 2 Id, 'Mike' Name").ToList();
Console.WriteLine($"Result: {persons.Count}");
Console.WriteLine($"1st person: {persons[0].ToJson()}");
Console.WriteLine($"2nd person: {persons[1].ToJson()}");

// Define the Person class
class Person
{
    public int? Id { get; set; }
    public string? Name { get; set; }
}
Enter fullscreen mode Exit fullscreen mode

Why Choose UkrGuru.Sql?

  • Open Source: Free to use and modify.
  • Community Support: Join a growing community of developers.
  • Documentation: Comprehensive guides and examples.

Give UkrGuru.Sql a try and see how it can streamline your database interactions!

Top comments (0)