Luke.SqlProxy.Core
1.0.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Luke.SqlProxy.Core --version 1.0.3
NuGet\Install-Package Luke.SqlProxy.Core -Version 1.0.3
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.3" />
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.3" />
<PackageReference Include="Luke.SqlProxy.Core" />
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.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Luke.SqlProxy.Core, 1.0.3"
#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.3
#: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.3
#tool nuget:?package=Luke.SqlProxy.Core&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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;");
ServiceCollection serviceCollection = new ServiceCollection();
serviceCollection.AddTransient<IProxyDbContext>((sp) => new ProxyDbContext(connection));
serviceCollection.AddProxyRepositoryFactory<IMyRepository>();
serviceCollection.AddTransientProxyRepository<IMyRepository>();
IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
IMyRepository proxy = serviceProvider.GetService<IMyRepository>();
DataTable dt = proxy.SelectData("Bob");
dt = proxy.SelectDataAsync("Bob").Result;
List<SysUser> users = proxy.SelectList("Bob");
users = proxy.SelectListAsync("Bob").Result;
SysUser user = proxy.SelectUser("Bob");
user = proxy.SelectUserAsync("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
{
[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);
[SelectEntity("select * from sys_user where name = @name;")]
SysUser SelectUser(string name);
[SelectEntity("select * from sys_user where name = @name;")]
Task<SysUser> SelectUserAsync(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);
}
ProxyDbContext
public class ProxyDbContext : IProxyDbContext, IDisposable
{
private readonly DbConnection _connection;
public ProxyDbContext(DbConnection connection)
{
_connection = connection;
}
public DbConnection GetCurrentDbConnection()
{
return _connection;
}
public void Dispose()
{
_connection.Dispose();
}
}
SysUser
public class SysUser
{
public int id { get; set; }
public string name { get; set; }
}
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. 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.
-
.NETStandard 2.1
- Castle.Core (>= 5.0.0)
- Castle.Core.AsyncInterceptor (>= 2.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
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.