LiteORM_v1 1.0.1
dotnet add package LiteORM_v1 --version 1.0.1
NuGet\Install-Package LiteORM_v1 -Version 1.0.1
<PackageReference Include="LiteORM_v1" Version="1.0.1" />
<PackageVersion Include="LiteORM_v1" Version="1.0.1" />
<PackageReference Include="LiteORM_v1" />
paket add LiteORM_v1 --version 1.0.1
#r "nuget: LiteORM_v1, 1.0.1"
#:package LiteORM_v1@1.0.1
#addin nuget:?package=LiteORM_v1&version=1.0.1
#tool nuget:?package=LiteORM_v1&version=1.0.1
LiteORM Integration Guide
This document provides instructions for integrating the LiteORM library into your .NET application as an alternative to ADO.NET or Dapper. Follow the steps below to configure and use LiteORM effectively.
Prerequisites
- Ensure the LiteORM library is installed in your project via NuGet.
- A valid database connection string must be configured in your application settings.
Configuration
Add the following code to your Program.cs file to configure LiteORM as a singleton service:
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddSingleton<ILiteORM>(provider => new LiteORMRepo(connectionString));
This code retrieves the database connection string from the configuration and registers LiteORMRepo as a singleton implementation of the ILiteORM interface.
Usage
Dependency Injection
Inject the ILiteORM interface into your repository or service class using constructor injection. Example:
private readonly ILiteORM _liteORM;
public CommonRepo(ILiteORM liteORM)
{
_liteORM = liteORM;
}
Querying Data
Use the QueryAllAsync method to execute SQL queries and retrieve data. Below is an example of fetching a list of users based on an optional UserId parameter:
public async Task<IEnumerable<PrUser>> GetUserList(int id)
{
var res = await _liteORM.QueryAllAsync<PrUser>(
"SELECT * FROM User WHERE (UserId = @Id OR @Id = 0)",
new { Id = id },
System.Data.CommandType.Text
);
return res;
}
This method executes a parameterized SQL query to retrieve PrUser entities, filtering by UserId or returning all users if id is 0.
Notes
- Ensure the connection string (
DefaultConnection) is defined in your configuration file (e.g.,appsettings.json). - The
ILiteORMinterface andLiteORMRepoclass must be properly implemented and available in your project. - Always use parameterized queries to prevent SQL injection vulnerabilities.
- For support or queries, please contact us at: dev-hemant@outlook.com
- To submit feedback or review this package, please mail us at: dev-hemant@outlook.com
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Data.SqlClient (>= 6.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.