ESqlFramework 3.0.0
dotnet add package ESqlFramework --version 3.0.0
NuGet\Install-Package ESqlFramework -Version 3.0.0
<PackageReference Include="ESqlFramework" Version="3.0.0" />
<PackageVersion Include="ESqlFramework" Version="3.0.0" />
<PackageReference Include="ESqlFramework" />
paket add ESqlFramework --version 3.0.0
#r "nuget: ESqlFramework, 3.0.0"
#:package ESqlFramework@3.0.0
#addin nuget:?package=ESqlFramework&version=3.0.0
#tool nuget:?package=ESqlFramework&version=3.0.0
ESqlFramework
You can visit my website edarkea
I'm tired of writing SQL code and the Entity Framework does not suit my needs as a developer. I've used Dapper but I must write SQL code for inserts, selects, update, etc... I'm forced to create a quick way to generate sql code for postgres, Which I called ESqlFramework.
There'are two version:
ESqlFramework 2.x for Net Core 7
ESqlFramework 1.x for Net Core 6
Program.cs
For configurate ESqlFramework into your project.
//ESqlFramework
builder.Services.Configure<ConnectionProperties>(builder.Configuration.GetSection(nameof(ConnectionProperties)));
builder.Services.AddSingleton<IConnectionProperties>(d => d.GetRequiredService<IOptions<ConnectionProperties>>().Value);
builder.Services.AddSingleton<IPgContext, PgContext>();
Into appsettings.json:
"ConnectionProperties": {
"connection": "Host=localhost;Port=5432;Database=my_database;User ID=postgres;Password=mypassword;Integrated Security=true;",
"timeout": 10000
}
Mapped Classes
Table
You should put Table annotation in your class, for example:
[Table(name = "my_table")]
public class MyClassModel{
//Properties
....
}
Remember use namespace:
using ESqlFramework;
The scheme by default is 'public' You can put other scheme into Table annotation, for example
[Table(name = "my_table", scheme = "other_scheme")]
public class MyClassModel {
//Properties
....
}
Column
For the primary key, you should put:
[Primary(isAutoIncremental = true)]
public long Id { get; set; }
if you have other name in yous database, you can use The Attributte Column.
[Primary(isAutoIncremental = true), Column("my_id")]
public long Id { get; set; }
Ignore
If you want ignore a column mapped, you should put a Ignore Attributte:
[Ignore]
public long MyCustomProperty { get; set; }
Repository Abstract Class
In layer data access or your favorite site for connection to database.
You should create a new class and inheritance Repository<T>, for example:
public class MyClassRepository : Repository<MyClassModel>
{
public MyClassRepository(IPgContext context) : base(context)
{
}
//Custom Code
}
You will have access to the functions:
public Entity insert(object item)
public Entity update(object item, object condition, params string[] except)
public Entity updateOnly(object item, object condition, params string[] only)
public Entity findOne(object condition)
public List<Entity> findMany(object condition)
public List<Entity> findPaginator(object condition, int limit = 20, int skip = 0, params string[] orderBy)
public void delete(object condition)
public List<Entity> filter(params Filter[] filters)
Implements in services
Implements this funtions in services like:
public class MyClassService
{
private readonly MyClassRepository repository;
public MyClassService(MyClassRepository repository)
{
this.repository = repository;
}
public MyClassModel addItem(MyClassModel model)
=> this.repository.insert(model);
public MyClassModel updateName(long Id, string cha_name)
=> this.repository
.updateOnly(new ChannelModel { cha_name = cha_name }, new { cha_id }, nameof(cha_name));
public void updatePrivacity(long Id, bool cha_privacy)
=> this.repository
.updateOnly(new ChannelModel { cha_privacy = cha_privacy }, new { Id }, nameof(cha_privacy));
public ChannelModel findById(long Id)
=> this.repository.findOne(new { Id });
}
- GitHub: https://github.com/edarkea
- Contact me: edison.ayui@outlook.com
Enjoy! 😃
| 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. 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. |
-
net7.0
- Dapper (>= 2.0.123)
- Npgsql (>= 6.0.7)
- Oracle.ManagedDataAccess.Core (>= 3.21.90)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.