Luke.SqlProxy.Core 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Luke.SqlProxy.Core --version 1.0.0
                    
NuGet\Install-Package Luke.SqlProxy.Core -Version 1.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="Luke.SqlProxy.Core" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Luke.SqlProxy.Core" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Luke.SqlProxy.Core" />
                    
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 Luke.SqlProxy.Core --version 1.0.0
                    
#r "nuget: Luke.SqlProxy.Core, 1.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 Luke.SqlProxy.Core@1.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=Luke.SqlProxy.Core&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Luke.SqlProxy.Core&version=1.0.0
                    
Install as a Cake Tool

Luke.SqlProxy

A Simple Proxy-Repository

How to use?

Program

static void Main(string[] args)
{
    DbConnection connection = new MySqlConnection("Database=dev_test;Data Source=127.0.0.1;User Id=root;Password=123456;CharSet=utf8mb4;port=3306;Old Guids=true;");

    IMyRepository productRepo = new MyRepository(connection);

    ServiceCollection serviceCollection = new ServiceCollection();

    serviceCollection.AddSingleton(productRepo);
    serviceCollection.AddProxyRepositoryFactory<IMyRepository>();
    
    IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();

    IProxyRepositoryFactory<IMyRepository> repositoryFactory = serviceProvider.GetService<IProxyRepositoryFactory<IMyRepository>>()!;

    IMyRepository proxy = repositoryFactory.CreateProxyRepository();

    DataTable dt = proxy.SelectData("Bob");
    dt = proxy.SelectDataAsync("Bob").Result;

    List<SysUser> users = proxy.SelectList("Bob");
    users = proxy.SelectListAsync("Bob").Result;
    
    proxy.DeleteUserAsync(2).Wait();

    int count = proxy.InserUser(new SysUser { id = 2, name = "test" });
    
    count = proxy.UpdateUser(new SysUser { id = 2, name = "test1" });
    count = proxy.UpdateUserAsync(new SysUser { id = 2, name = "test2" }).Result;
    
    Console.Read();
}

IMyRepository

public interface IMyRepository : IProxyRepository
{

    [SelectTable("select * from sys_user where name = @name;")]
    DataTable SelectData(string name);

    [SelectTable("select * from sys_user where name = @name;")]
    Task<DataTable> SelectDataAsync(string name);

    [SelectList("select * from sys_user where name = @name;")]
    List<SysUser> SelectList(string name);

    [SelectList("select * from sys_user where name = @name;")]
    Task<List<SysUser>> SelectListAsync(string name);

    [Insert("insert into sys_user(id, name) values (@id, @name);")]
    int InserUser(SysUser user);

    [Update("update sys_user set name = @name where id = @id;")]
    int UpdateUser(SysUser user);

    [Update("update sys_user set name = @name where id = @id;")]
    Task<int> UpdateUserAsync(SysUser user);

    [Delete("delete from sys_user where id = @id;")]
    void DeleteUser([DbParameterName("id")]int testid);

    [Delete("delete from sys_user where id = @id;")]
    Task DeleteUserAsync([DbParameterName("id")] int testid);

}

MyRepository

public class MyRepository : IMyRepository
{
    private readonly DbConnection _connection;
    public MyRepository(DbConnection connection)
    {
        _connection = connection;
    }

    public DbConnection GetCurrentDbConnection()
    {
        return _connection;
    }

    
    public DataTable SelectData(string name)
    {
        throw new NotImplementedException();
    }

    public List<SysUser> SelectList(string name)
    {
        throw new NotImplementedException();
    }

    public int InserUser(SysUser user)
    {
        throw new NotImplementedException();
    }

    public int UpdateUser(SysUser user)
    {
        throw new NotImplementedException();
    }

    public void DeleteUser(int id)
    {
        throw new NotImplementedException();
    }

    public Task<DataTable> SelectDataAsync(string name)
    {
        throw new NotImplementedException();
    }

    public Task<List<SysUser>> SelectListAsync(string name)
    {
        throw new NotImplementedException();
    }

    public Task<int> UpdateUserAsync(SysUser user)
    {
        throw new NotImplementedException();
    }

    public Task DeleteUserAsync([DbParameterName("id")] int testid)
    {
        throw new NotImplementedException();
    }
}

SysUser

public class SysUser
{
    public int id { get; set; }
    public string name { get; set; }
}
Product 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.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Luke.SqlProxy.Core:

Package Downloads
Luke.SqlProxy.Dapper

A Simple Proxy-Repository

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 135 5/2/2025
1.0.5 157 5/1/2025
1.0.4 102 4/26/2025
1.0.3 181 4/20/2025
1.0.2 127 4/19/2025
1.0.1 137 12/31/2024
1.0.0 168 12/13/2024