ZayniFramework.DataAccess
2.0.1
See the version list below for details.
dotnet add package ZayniFramework.DataAccess --version 2.0.1
NuGet\Install-Package ZayniFramework.DataAccess -Version 2.0.1
<PackageReference Include="ZayniFramework.DataAccess" Version="2.0.1" />
paket add ZayniFramework.DataAccess --version 2.0.1
#r "nuget: ZayniFramework.DataAccess, 2.0.1"
// Install ZayniFramework.DataAccess as a Cake Addin #addin nuget:?package=ZayniFramework.DataAccess&version=2.0.1 // Install ZayniFramework.DataAccess as a Cake Tool #tool nuget:?package=ZayniFramework.DataAccess&version=2.0.1
DataAccess & ORM example.
Just like using Dapper.
- Support Microsoft SQL Server, MySQL and Oracle database with same Dao class.
- Support SQL log (input SQL statement & output results).
- Support ORM.
- Support dynamic ORM.
- Support DataContext CURD template.
- Support database schema migration CLI tool.
- NO MORE Entity Framework!!!
Add config in your app.config or web.config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="ZayniFramework" type="ZayniFramework.Common.ZayniConfigSection, ZayniFramework.Common"/>
</configSections>
<ZayniFramework>
<LoggingSettings eventLogEnable="false" logEnable="true">
<DefaultTextLogger>
<add name="_DefaultLog" enable="true" maxSize="8">
<LogFile path="D:\Logs\Zayni\Tracing.log"/>
<Filter filterType="deny" category="Information,Warning"/>
</add>
</DefaultTextLogger>
</LoggingSettings>
<DataAccessSettings>
<DatabaseProviders>
<add name="Zayni" dataBaseProvider="MSSQL" sqlLogEnable="true"/>
<add name="ZayniUnitTest" dataBaseProvider="MSSQL" sqlLogEnable="true"/>
</DatabaseProviders>
</DataAccessSettings>
</ZayniFramework>
<connectionStrings>
<add name="Zayni" connectionString="Server=XXX;Database=XXX;User Id=XXX;Password=XXX;Max Pool Size=20;Min Pool Size=5;Connection Lifetime=30;"
providerName="System.Data.SqlClient" />
<add name="ZayniUnitTest" connectionString="Server=XXX;Database=XXX;User Id=XXX;Password=XXX;Max Pool Size=20;Min Pool Size=5;Connection Lifetime=30;"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Add using.
using ZayniFramework.Common;
using ZayniFramework.DataAccess;
Write your Dao (Data Access Object) class and extends the BaseDataAccess class.
/// <summary>Your Data Access Object (Dao) class
/// </summary>
internal class UserDao : BaseDataAccess
Select data from database using BaseDataAccess.LoadDataToModel() method.
public Result<List<UserModel>> Select_LoadDataToModel_Example( UserModel query )
{
var result = new Result<List<UserModel>>()
{
IsSuccess = false,
Data = null
};
string sql = @"SELECT AccountId
, Name
, Age
, Sex
, Birthday
, IsVIP
, IsGood
, DataFlag
FROM fs_unit_test_user
WHERE Sex = @Sex ";
DbCommand cmd = base.GetSqlStringCommand( sql );
base.AddInParameter( cmd, "@Sex", DbTypeCode.Int32, query.Sex );
if ( !base.LoadDataToModel( cmd, out List<UserModel> models ) )
{
result.Message = base.Message;
return result;
}
result.Data = models;
result.IsSuccess = true;
return result;
}
Multi-select SQL statements from database by using BaseDataAccess.LoadDataToModels() method.
public Result Select_LoadDataToModels( UserModel query )
{
dynamic result = new Result()
{
IsSuccess = false,
Message = null
};
string sql = @" -- QueryNo1
SELECT AccountId AS Account
, Name
, Age
, Sex
, Birthday AS DoB
, IsVIP
FROM fs_unit_test_user
WHERE Sex = @Sex;
-- QueryNo2
SELECT AccountId AS Account
, Name
, Age
, Sex
, Birthday AS DoB
FROM fs_unit_test_user
WHERE Sex = @Sex; ";
DbCommand cmd = base.GetSqlStringCommand( sql );
base.AddInParameter( cmd, "@Sex", DbTypeCode.Int32, query.Sex );
Type[] types = { typeof ( UserModel ), typeof ( UserModel ) };
if ( !base.LoadDataToModels( cmd, types, out List<object[]> datas ) )
{
return result;
}
List<UserModel> queryResult1 = datas.FirstOrDefault().ToList<UserModel>();
List<UserModel> queryResult2 = datas.LastOrDefault().ToList<UserModel>();
result.Rst1 = queryResult1;
result.Rst2 = queryResult2;
result.IsSuccess = true;
return result;
}
Dynamic ORM query using BaseDataAccess.LoadDataToDynamicModel() method. You don't need to define a entity class anymore.
public Result<List<dynamic>> Select_LoadDataToDynamicModel_Example( UserModel query )
{
var result = new Result<List<dynamic>>()
{
IsSuccess = false,
Data = null
};
string sql = @"SELECT AccountId AS Account
, Name
, Age
, Sex
, Birthday AS DoB
, IsVIP
FROM fs_unit_test_user
WHERE Sex = @Sex ";
DbCommand cmd = base.GetSqlStringCommand( sql );
base.AddInParameter( cmd, "@Sex", DbTypeCode.Int32, query.Sex );
List<dynamic> models;
if ( !base.LoadDataToDynamicModel( cmd, out models ) )
{
result.Message = base.Message;
return result;
}
result.Data = models;
result.IsSuccess = true;
return result;
}
For more BaseDataAccess examples see here.
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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- MySql.Data (>= 8.0.12)
- System.Data.SqlClient (>= 4.5.1)
- ZayniFramework.Common (>= 2.0.1)
- ZayniFramework.Logging (>= 2.0.1)
- ZayniFramework.Serialization (>= 2.0.1)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on ZayniFramework.DataAccess:
Package | Downloads |
---|---|
ZayniFramework.Middle.Service
The Middle.Service module provide a self-hosted .NET middleware framework to separate the communication protocol detail with your business logic code. You can use it to build the backend microservices easier. Support TCPSocket, WebSocket and RabbitMQ protocol. You can also implement the IRemoteHost interface and register it into the Middle.Service module as an extension module for this middleware framework. Have a nice day... :) GitLab Repository: https://gitlab.com/ponylin1985/zayniframework |
|
ZayniFramework.Middle.Service.Client
The Middle.Service.Client is the client SDK for Middle.Service module. You can use it to connect, send RPC request or publish message to the server side's service host very easy. Support TCPSocket, WebSocket and RabbitMQ protocol. GitLab Repository: https://gitlab.com/ponylin1985/zayniframework |
|
ZayniFramework.Caching
This is a cache management for .NET application. You can store you data in memory, redis and MySQL memory table engine. GitLab Repository: https://gitlab.com/ponylin1985/zayniframework |
|
ZayniFramework.DataAccess.LightORM
This is a lightweight CRUD ORM template for .NET data access application. You can use the DataContext to execute Insert, Update, Delete and Select action to database. Currently only support the MSSQL and MySQL database. GitLab Repository: https://gitlab.com/ponylin1985/zayniframework |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.142 | 262 | 3/19/2024 |
8.0.141 | 388 | 1/4/2024 |
8.0.140 | 432 | 12/17/2023 |
6.0.138 | 311 | 3/19/2024 |
6.0.137 | 739 | 9/20/2023 |
6.0.136 | 737 | 9/14/2023 |
6.0.135 | 781 | 9/10/2023 |
6.0.134 | 918 | 7/12/2023 |
6.0.133 | 960 | 7/10/2023 |
6.0.132 | 952 | 7/7/2023 |
6.0.131 | 1,015 | 6/19/2023 |
6.0.130 | 963 | 6/19/2023 |
6.0.129 | 12,275 | 7/2/2022 |
6.0.128 | 2,241 | 1/16/2022 |
6.0.127 | 2,235 | 1/15/2022 |
6.0.126 | 2,077 | 1/15/2022 |
6.0.125 | 1,485 | 1/8/2022 |
6.0.125-hotfix1 | 953 | 1/8/2022 |
6.0.124 | 1,568 | 1/7/2022 |
6.0.123 | 1,728 | 11/14/2021 |
5.0.129 | 2,820 | 7/2/2022 |
5.0.128 | 2,965 | 1/16/2022 |
5.0.125 | 1,719 | 1/8/2022 |
5.0.124 | 1,716 | 1/7/2022 |
5.0.123 | 2,132 | 11/14/2021 |
5.0.122 | 2,294 | 10/11/2021 |
5.0.121 | 2,339 | 5/1/2021 |
3.1.137 | 1,136 | 9/20/2023 |
3.1.136 | 1,049 | 9/14/2023 |
3.1.135 | 1,166 | 9/10/2023 |
3.1.134 | 1,421 | 7/12/2023 |
3.1.133 | 1,458 | 7/11/2023 |
3.1.132 | 1,393 | 7/8/2023 |
3.1.131 | 1,481 | 6/19/2023 |
3.1.130 | 2,382 | 2/1/2023 |
3.1.129 | 4,117 | 7/2/2022 |
3.1.128 | 4,318 | 1/16/2022 |
3.1.125 | 2,363 | 1/8/2022 |
3.1.124 | 2,289 | 1/7/2022 |
3.1.123 | 2,876 | 11/14/2021 |
3.1.122 | 3,226 | 10/11/2021 |
3.1.121 | 3,358 | 5/1/2021 |
2.31.120 | 2,348 | 3/14/2021 |
2.30.115 | 5,992 | 3/6/2021 |
2.30.114 | 2,265 | 3/6/2021 |
2.20.101 | 2,939 | 3/1/2021 |
2.19.3 | 2,379 | 2/11/2021 |
2.19.2 | 14,631 | 2/6/2021 |
2.19.1 | 2,653 | 1/6/2021 |
2.19.0 | 2,657 | 1/1/2021 |
2.18.3 | 4,064 | 12/27/2020 |
2.18.2 | 5,076 | 8/29/2020 |
2.18.1 | 8,239 | 8/26/2020 |
2.18.0 | 8,427 | 8/20/2020 |
2.17.135 | 4,231 | 8/19/2020 |
2.17.134 | 4,332 | 7/28/2020 |
2.17.133 | 4,315 | 7/27/2020 |
2.17.132 | 4,242 | 7/18/2020 |
2.17.131 | 4,351 | 7/11/2020 |
2.16.130 | 4,158 | 6/13/2020 |
2.15.128 | 4,295 | 6/3/2020 |
2.15.127 | 4,221 | 5/31/2020 |
2.15.126 | 5,169 | 4/30/2020 |
2.14.122 | 3,983 | 4/13/2020 |
2.13.100 | 4,185 | 3/12/2020 |
2.12.51 | 4,182 | 2/18/2020 |
2.11.50 | 8,844 | 2/10/2020 |
2.10.44 | 10,416 | 1/30/2020 |
2.9.43 | 10,293 | 1/11/2020 |
2.8.42 | 10,421 | 1/10/2020 |
2.8.41 | 10,295 | 1/5/2020 |
2.7.40 | 10,114 | 1/2/2020 |
2.7.39 | 10,102 | 1/2/2020 |
2.7.38 | 10,384 | 1/1/2020 |
2.6.37 | 10,202 | 12/23/2019 |
2.6.35 | 10,459 | 12/4/2019 |
2.6.1 | 10,349 | 12/2/2019 |
2.6.0 | 10,152 | 11/28/2019 |
2.5.2 | 10,521 | 11/26/2019 |
2.5.1 | 10,262 | 11/12/2019 |
2.5.0 | 10,045 | 11/9/2019 |
2.4.3 | 10,238 | 10/16/2019 |
2.4.2 | 9,666 | 10/16/2019 |
2.4.1 | 9,675 | 9/20/2019 |
2.3.113 | 2,257 | 3/6/2021 |
2.3.112 | 2,232 | 3/6/2021 |
2.3.28 | 9,453 | 9/19/2019 |
2.3.27 | 9,662 | 8/30/2019 |
2.3.26 | 9,699 | 8/20/2019 |
2.3.25 | 9,522 | 8/12/2019 |
2.3.22 | 9,775 | 7/31/2019 |
2.3.21 | 9,522 | 7/20/2019 |
2.3.20 | 9,216 | 6/22/2019 |
2.3.19 | 9,666 | 6/14/2019 |
2.3.18 | 9,931 | 6/13/2019 |
2.3.17 | 9,647 | 6/13/2019 |
2.3.15 | 9,438 | 6/8/2019 |
2.3.14 | 9,329 | 6/8/2019 |
2.3.13 | 9,568 | 5/30/2019 |
2.3.12 | 4,890 | 5/24/2019 |
2.3.11 | 4,804 | 5/24/2019 |
2.3.10 | 4,918 | 5/21/2019 |
2.3.9 | 4,658 | 5/9/2019 |
2.3.8 | 5,050 | 5/8/2019 |
2.3.7 | 5,034 | 4/30/2019 |
2.3.6 | 5,018 | 4/23/2019 |
2.3.5 | 4,941 | 4/19/2019 |
2.3.4 | 4,885 | 4/18/2019 |
2.3.3 | 4,822 | 4/17/2019 |
2.3.2 | 5,061 | 4/6/2019 |
2.3.1 | 4,989 | 12/15/2018 |
2.3.0 | 5,058 | 12/7/2018 |
2.2.6 | 7,796 | 11/25/2018 |
2.2.1 | 13,678 | 11/17/2018 |
2.2.0 | 4,050 | 11/16/2018 |
2.1.0 | 3,927 | 11/15/2018 |
2.0.1 | 2,552 | 11/6/2018 |
2.0.0 | 2,714 | 11/4/2018 |