NPrismy 1.0.7
See the version list below for details.
dotnet add package NPrismy --version 1.0.7
NuGet\Install-Package NPrismy -Version 1.0.7
<PackageReference Include="NPrismy" Version="1.0.7" />
paket add NPrismy --version 1.0.7
#r "nuget: NPrismy, 1.0.7"
// Install NPrismy as a Cake Addin
#addin nuget:?package=NPrismy&version=1.0.7
// Install NPrismy as a Cake Tool
#tool nuget:?package=NPrismy&version=1.0.7
NPrismy - A Lightweight .NET Core ORM Framework
NPrismy is lightweight ORM for ASP.NET Core Web Applications.
Give a hand! NPrismy needs some features to be implemented.
- Add MySql support
- Add Oracle Db support
- Add benchmark results
- Implement RollbackAsync() method.
Table Of Contents
Features
- Simple CRUD operations with sugar syntax.
- Using database transactions
- Customized entity mappings
- Managing persistance concerns with a high level language
Installation
Install NPrismy NuGet package by executing following command on .NET Core CLI:
dotnet add package NPrismy
and
PM> Install-Package NPrismy
on NuGet Package Manager Console.
Usage
Step by step initialization.
1) Create a Database class
Create a database class that inherited from NPrismy.Database abstract class. (i.e. CarFactoryDatabase) Database classes are represents the remote database. (Like EF DbContext)
public class WeatherForecastDatabase : NPrismy.Database
{
}
2) Add NPrismy support
Insert the following code to your Startup.cs ConfigureServices() method to register your database object to ServiceCollection.
services.AddNPrismy<WeatherForecastDatabase>()
.UseProvider(PersistanceProvider.SqlServer)
.ConnectionString("#your-connection-string#");
- Specify the connection string by passing it to
ConnectionString()
method. - Specify the your persistance provider (SqlServer, Oracle DB, MySql) by calling
UseProvider()
method. (ONLY MICROSOFT SQL SERVER SUPPORTED AT THE MOMENT)
3) Specify your tables
Add EntityTable<T>
properties to your database class to specify your database tables.
public class WeatherForecastDatabase : NPrismy.Database
{
public EntityTable<City> Cities { get; set; }
public EntityTable<Forecast> Forecasts { get; set; }
}
4) Specify table names and schemas (optional)
As default, NPrismy pluralizes the property types of database class. And assumes they are in the dbo
schema. In the above example, NPrismy assumes there are two different tables named dbo.Cities
and dbo.Forecasts
. Regardless of the names of properties, NPrismy pluralizes the types City
and Foreacast
.
If you override these definitions, simply put [TableName]
and [Schema]
attributes as following.
public class WeatherForecastDatabase : NPrismy.Database
{
[TableName("MyCities")]
[Schema("weatherForecast")]
public EntityTable<City> Cities { get; set; }
[TableName("AwesomeForecasts")]
[Schema("weatherForecast")]
public EntityTable<Forecast> Forecasts { get; set; }
}
5) Do your CRUD!
Modify your controllers as accepts WeatherForecastDatabase
(how you name it) and you're done. Querying data can be performed as following:
var lovelyCities = _db.Cities.Query(c => c.Name == "Istanbul" || c.Name == "Copenhagen");
Examples
Query Data
- Querying all data from table.
var cities = await _database.Cities.Query();
- Querying with where clause
`var cities = await _database.Cities.Query(c ⇒ c.Name == 'Copenhagen');
- Getting by primary key
var city = await _database.Cities.FindByPrimaryKey(1); //Gets the city with ID '1' (or whatever the primary key)
Insert Data
var city = new City(name: "Paris", country: "FR");
_database.Cities.Add(city);
_database.Commit(); //Don't forget to commit
Update Data
var city = await _database.Cities.FindByPrimaryKey(10);
city.Name = "Paris";
_database.Cities.Update(city);
_database.Commit();
Delete Data
- Deleting with LINQ expression
_database.Cities.Delete(c => c.Name == "Copenhagen");
_database.Commit();
- Deleting by Primary Key
_database.Cities.Delete(1); //Deletes the city with ID 1
_database.Commit();
Benchmark
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Autofac (>= 6.0.0)
- Microsoft.Data.SqlClient (>= 2.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.1.0)
- Newtonsoft.json (>= 12.0.3)
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.1.4 | 428 | 10/29/2020 |
1.1.3 | 363 | 10/28/2020 |
1.1.2 | 406 | 10/17/2020 |
1.1.1 | 360 | 10/17/2020 |
1.1.0 | 429 | 10/17/2020 |
1.0.9 | 446 | 10/17/2020 |
1.0.8 | 465 | 10/16/2020 |
1.0.7 | 457 | 10/16/2020 |
1.0.6 | 467 | 10/16/2020 |
0.9.8 | 380 | 10/16/2020 |
0.9.7 | 369 | 10/16/2020 |
0.9.6 | 378 | 10/16/2020 |
0.9.5 | 426 | 10/15/2020 |
0.9.4 | 407 | 10/14/2020 |
0.9.3 | 584 | 10/13/2020 |
0.9.2 | 587 | 10/13/2020 |
Added IgnoreProperty attribute.