ESqlFramework 3.0.0

dotnet add package ESqlFramework --version 3.0.0
                    
NuGet\Install-Package ESqlFramework -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ESqlFramework" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ESqlFramework" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ESqlFramework" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ESqlFramework --version 3.0.0
                    
#r "nuget: ESqlFramework, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ESqlFramework@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ESqlFramework&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ESqlFramework&version=3.0.0
                    
Install as a Cake Tool

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 });
    }

Enjoy! 😃

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
3.0.0 381 3/16/2023
2.2.3 397 3/12/2023
2.2.2 453 1/24/2023
2.2.1 435 12/12/2022
2.2.0 437 12/12/2022
2.1.1 452 12/10/2022
2.1.0 438 12/10/2022
2.0.0 468 12/8/2022
1.2.1 435 12/12/2022
1.2.0 434 12/12/2022
1.1.0 448 12/10/2022
1.0.0 462 12/8/2022