NiORM 1.3.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package NiORM --version 1.3.8                
NuGet\Install-Package NiORM -Version 1.3.8                
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="NiORM" Version="1.3.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NiORM --version 1.3.8                
#r "nuget: NiORM, 1.3.8"                
#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 NiORM as a Cake Addin
#addin nuget:?package=NiORM&version=1.3.8

// Install NiORM as a Cake Tool
#tool nuget:?package=NiORM&version=1.3.8                

NiORM

NiORM is a lightweight Object-Relational Mapper (ORM) for .NET, designed to simplify interactions with SQL databases. It uses a convention-over-configuration approach, enabling developers to map C# classes to database tables using attributes. NiORM offers an intuitive interface for querying and manipulating data with minimal overhead.

Features

  • Attribute-based Mapping: Use [TableName], [PrimaryKey], and other annotations to define the schema directly in your C# classes.
  • Entity Management: Create, retrieve, update, and delete records easily through Entities<T> collections.
  • Query Simplification: Chain LINQ-style queries for simple and advanced data filtering.
  • Raw SQL Execution: Execute raw SQL queries when needed, returning mapped objects.
  • Multiple Database Support: Handle multiple databases within the same project.

Installation

Download & Install the nuget using:

Nuget Package Manager:

NuGet\Install-Package NiORM -Version 1.3.7

.Net CLI:

dotnet add package NiORM --version 1.3.7

Quick Start

Here’s how you can get started with NiORM in your application:

1. Define a Model:

Use attributes like [TableName] and [PrimaryKey] to map a C# class to a database table.

using NiORM.Attributes;
using NiORM.SQLServer.Interfaces;

[TableName("People")]
public class Person : ITable
{
    [PrimaryKey(isAutoIncremental: true)]
    public int Id { get; set; }
    public string Name { get; set; }
    public int Age { get; set; }
}
2. Set up a Data Service:

Create a service class that inherits from DataCore. This class will act as the interface between your application and the database.

using NiORM.SQLServer;
using NiORM.Test.Models;

public class DataService : DataCore
{
    public DataService(string connectionString) : base(connectionString) { }

    public IEntities<Person> People => CreateEntity<Person>();
}
3. Interact with the Database:

Use the data service to fetch, insert, update, and delete records.

var dataService = new DataService("your-connection-string-here");

// Fetch all people
var people = dataService.People.ToList();

// Add a new person
var newPerson = new Person() { Age = 29, Name = "Nima" };
dataService.People.Add(newPerson);

// Query with conditions
var filteredPeople = dataService.People.Where(p => p.Name == "Nima").ToList();
4. Execute Raw SQL (when necessary):

If you need more control, you can execute raw SQL queries and map them to your models.

var cats = dataService.SqlRaw<Cat>("SELECT * FROM Cats");

Contributing

We welcome contributions! Please fork the repository and submit pull requests for any improvements or features you'd like to add.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.3.13 69 11/17/2024
1.3.12 69 11/16/2024
1.3.11 89 10/14/2024
1.3.10 93 10/2/2024
1.3.9 94 10/2/2024
1.3.8 93 9/29/2024
1.3.7 90 9/29/2024
1.3.6 83 9/29/2024
1.3.5 89 9/29/2024
1.3.4 95 9/26/2024
1.3.3 96 9/26/2024
1.3.2 107 9/23/2024
1.3.1 92 9/23/2024
1.2.10 242 8/22/2023
1.2.9 200 6/13/2023
1.2.8 155 5/29/2023
1.2.7 199 4/24/2023
1.2.6 186 4/20/2023
1.2.5 204 4/16/2023
1.2.4 200 4/16/2023
1.2.3 227 4/8/2023
1.2.2 216 4/8/2023
1.2.1 211 4/8/2023
1.1.6 200 4/5/2023
1.1.5 272 2/15/2023
1.1.4 257 2/15/2023
1.1.3 328 1/28/2023
1.1.2 306 1/28/2023
1.1.1 370 1/15/2023
1.0.2 318 1/9/2023
1.0.1 328 1/8/2023
1.0.0 323 1/8/2023

this version supports enum implementation