RedOrb 0.5.9
dotnet add package RedOrb --version 0.5.9
NuGet\Install-Package RedOrb -Version 0.5.9
<PackageReference Include="RedOrb" Version="0.5.9" />
paket add RedOrb --version 0.5.9
#r "nuget: RedOrb, 0.5.9"
// Install RedOrb as a Cake Addin #addin nuget:?package=RedOrb&version=0.5.9 // Install RedOrb as a Cake Tool #tool nuget:?package=RedOrb&version=0.5.9
RedOrb
Simple, Intuitive, ORM
ORM for people who simply want to access a database.
Demo
Although a configuration file is required, CRUD processing is very simple to write.
using RedOrb;
using RedOrb.Attributes;
using System.Data;
// configuration
ObjectRelationMapper.PlaceholderIdentifer = ":";
ObjectRelationMapper.AddTypeHandler(DefinitionBuilder.Create<Blog>());
// database connection processing is omitted as it is out of scope.
using IDbConnection cn = null!;
// create table
cn.CreateTableOrDefault<Blog>();
// insert
var c = new Blog { Url = "test" };
cn.Save(c);
// primary key search
var blog = cn.Load(new Blog { BlogId = 1 });
[DbTable("blogs")]
public class Blog
{
[DbColumn("serial8", IsAutoNumber = true, IsPrimaryKey = true)]
public int BlogId { get; set; }
[DbColumn("text")]
public string Url { get; set; } = string.Empty;
}
Features
General
- Connection classes are not hidden
- Supports SQL logging
- DBMS independent
- Supports sequence keys
- Supports composite keys
When reading
- All tables with a 1:1 or 1:0..1 relationship are joined and read (default)
- You can set whether to join tables.
- You can use primary key search and unique key search.
- You can also specify any search conditions.
When saving
- All tables with 1 to 0..N relationships are saved.
Constraints
General
- Connection class generation is out of scope
When loading
- Column filtering is not possible.
When saving
- If the primary key value is zero, it is considered to be added. (Primary key value cannot be registered with zero)
Getting started
PM> NuGet\Install-Package RedOrb
Configuration
Register the type mapping only once before using RedOrb.
using RedOrb;
using RedOrb.Attributes;
ObjectRelationMapper.PlaceholderIdentifer = ":";
ObjectRelationMapper.AddTypeHandler(DefinitionBuilder.Create<Blog>());
Create Table
using RedOrb;
using IDbConnection cn = SomethingMethod();
cn.CreateTableOrDefault<Blog>();
create table if not exists blogs (
blog_id serial8 not null,
url text not null,
primary key(blog_id)
)
Create(Insert)
using RedOrb;
using IDbConnection cn = SomethingMethod();
var newBlog = new Blog { Url = "http://blogs.msdn.com/adonet" };
Assert.Equal(0, newBlog.BlodId);
cn.Save(newBlog);
Assert.NotEqual(0, newBlog.BlodId);
/*
Url = '"http://blogs.msdn.com/adonet'
*/
insert into blogs (url)
SELECT
v.url
FROM
(
VALUES
(:Url)
) AS v (
url
)
returning blog_id;
Read(Select)
using RedOrb;
using IDbConnection cn = SomethingMethod();
var blog = cn.Load(new Blog() { BlodId = 1 });
/*
key0 = 1
*/
SELECT
t0.blog_id AS t0BlogId,
t0.url AS t0Url
FROM
blogs AS t0
WHERE
t0.blog_id = :key0
Update
using RedOrb;
using IDbConnection cn = SomethingMethod();
var blog = cn.Load(new Blog() { BlodId = 1 });
blog.Url = "https://devblogs.microsoft.com/dotnet";
cn.Save(blog);
/*
BlogId = 1
Url = 'https://devblogs.microsoft.com/dotnet'
*/
UPDATE
blogs AS d
SET
url = q.url
FROM
(
SELECT
v.blog_id,
v.url
FROM
(
VALUES
(:BlogId, :Url)
) AS v (
blog_id, url
)
) AS q
WHERE
d.blog_id = q.blog_id;
Delete
using RedOrb;
using IDbConnection cn = SomethingMethod();
cn.Delete(new Blog() { BlodId = 1 });
/*
BlogId = 1
*/
delete from blogs as d
where
(d.blog_id) in (select v.blog_id from (values (:BlogId)) as v (blog_id));
Advanced usage
Please refer to the wiki for advanced usage such as how to write a Model, Fetch, and CascadeRule. https://github.com/mk3008/RedOrb/wiki
Referenced Libraries
UTF8JSON / MIT License
https://github.com/neuecc/Utf8Json/
https://github.com/neuecc/Utf8Json/blob/master/LICENSE
Copyright (c) 2017 Yoshifumi Kawai
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Carbunql / MIT License
https://github.com/mk3008/Carbunql
https://github.com/mk3008/Carbunql/blob/main/LICENSE
Copyright (c) 2022 MSugiura
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. |
-
net7.0
- Carbunql (>= 0.5.6)
- Carbunql.Dapper (>= 0.2.0)
- Microsoft.Extensions.Logging (>= 7.0.0)
- Utf8Json (>= 1.3.7)
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 |
---|---|---|
0.5.9 | 160 | 1/13/2024 |
0.5.8 | 137 | 1/5/2024 |
0.5.7 | 109 | 1/3/2024 |
0.5.6 | 119 | 12/31/2023 |
0.5.3 | 117 | 12/29/2023 |
0.5.2.2 | 112 | 12/27/2023 |
0.5.2.1 | 127 | 12/27/2023 |
0.5.2 | 117 | 12/27/2023 |
0.5.1 | 121 | 12/25/2023 |
0.5.0 | 142 | 12/24/2023 |
0.4.1 | 123 | 12/17/2023 |
0.4.0 | 117 | 12/17/2023 |
0.3.1 | 122 | 12/16/2023 |
0.3.0 | 116 | 12/16/2023 |
0.2.1 | 118 | 12/16/2023 |
0.2.0 | 130 | 12/16/2023 |
0.1.0 | 134 | 9/10/2023 |