NiORM 1.3.3
See the version list below for details.
dotnet add package NiORM --version 1.3.3
NuGet\Install-Package NiORM -Version 1.3.3
<PackageReference Include="NiORM" Version="1.3.3" />
paket add NiORM --version 1.3.3
#r "nuget: NiORM, 1.3.3"
// Install NiORM as a Cake Addin #addin nuget:?package=NiORM&version=1.3.3 // Install NiORM as a Cake Tool #tool nuget:?package=NiORM&version=1.3.3
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.2
.Net CLI:
dotnet add package NiORM --version 1.3.2
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 Entities<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 | Versions 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. |
-
net6.0
- MongoDB.Driver (>= 2.19.1)
- System.Data.SqlClient (>= 4.8.6)
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 | 89 | 11/17/2024 |
1.3.12 | 79 | 11/16/2024 |
1.3.11 | 96 | 10/14/2024 |
1.3.10 | 99 | 10/2/2024 |
1.3.9 | 100 | 10/2/2024 |
1.3.8 | 100 | 9/29/2024 |
1.3.7 | 95 | 9/29/2024 |
1.3.6 | 89 | 9/29/2024 |
1.3.5 | 95 | 9/29/2024 |
1.3.4 | 101 | 9/26/2024 |
1.3.3 | 102 | 9/26/2024 |
1.3.2 | 113 | 9/23/2024 |
1.3.1 | 100 | 9/23/2024 |
1.2.10 | 246 | 8/22/2023 |
1.2.9 | 202 | 6/13/2023 |
1.2.8 | 157 | 5/29/2023 |
1.2.7 | 201 | 4/24/2023 |
1.2.6 | 190 | 4/20/2023 |
1.2.5 | 207 | 4/16/2023 |
1.2.4 | 202 | 4/16/2023 |
1.2.3 | 229 | 4/8/2023 |
1.2.2 | 218 | 4/8/2023 |
1.2.1 | 213 | 4/8/2023 |
1.1.6 | 202 | 4/5/2023 |
1.1.5 | 274 | 2/15/2023 |
1.1.4 | 260 | 2/15/2023 |
1.1.3 | 330 | 1/28/2023 |
1.1.2 | 308 | 1/28/2023 |
1.1.1 | 372 | 1/15/2023 |
1.0.2 | 320 | 1/9/2023 |
1.0.1 | 330 | 1/8/2023 |
1.0.0 | 327 | 1/8/2023 |
this version includes some optimization in coding and uses CustomeAttributes
for finding a better way please see NiORM.Test project in github repository.