DevelopmentHelpers.QueryBuilder
1.0.0
See the version list below for details.
dotnet add package DevelopmentHelpers.QueryBuilder --version 1.0.0
NuGet\Install-Package DevelopmentHelpers.QueryBuilder -Version 1.0.0
<PackageReference Include="DevelopmentHelpers.QueryBuilder" Version="1.0.0" />
paket add DevelopmentHelpers.QueryBuilder --version 1.0.0
#r "nuget: DevelopmentHelpers.QueryBuilder, 1.0.0"
// Install DevelopmentHelpers.QueryBuilder as a Cake Addin #addin nuget:?package=DevelopmentHelpers.QueryBuilder&version=1.0.0 // Install DevelopmentHelpers.QueryBuilder as a Cake Tool #tool nuget:?package=DevelopmentHelpers.QueryBuilder&version=1.0.0
DevelopmentHelpers.QueryBuilder
This library allows a way to build Query and export data in Json and Xml from SQL SERVER .net core applicaitons
Code Example
To Create a Query From Xml File 1. XElement queryElement = XElement.Load(filePath); var helper = new QueryMapper(); Query query = helper.Get(queryElement); 2. Create MSSQL server Data Store Helper var logger = (ILogger<SqlDataStoreHelper>)KernelMapper.ServiceProvider.GetService(typeof(ILogger<SqlDataStoreHelper>)); IDataStoreHelper dataStoreHelper = new SqlDataStoreHelper(logger, KernelMapper.NorthWindConnectionString);
2. Create a Datatable from Query for MSSQL Server FOR SELECT Statement
DataTable dataTable = await dataStoreHelper.GetDataTableAsync(query);
3. Add Query to Database
List<Parameter> parameters = await dataStoreHelper.AddAsync(query);
var primaryKeyParameter = parameterMapper.GetParameter("Your Parameter Name ",parameters);
4. Delete Query
bool deleted = await dataStoreHelper.DeleteAsync(query);
5. Update Or Add Query without parameters, return no of rows affected
int saved = await dataStoreHelper.SaveAsync(query);
6. Create a Table Mapper for xml and Json formats
TableMapper tableMapper = new TableMapper();
7. Create a Table from DataTable
Table table = tableMapper.Get(dataTable);
8. Create xml From Table Mapper
XElement xElement = tableMapper.GetXml(table);
9. Create Json from Table Mapper
JsonDocument json = tableMapper.GetJson(model);
10. Validate Json/Xml with var validateHelper = new ValidateHelper();
bool isXmlValid = validateHelper.IsValidXml(xElement.ToString());
bool isJsonValid = validateHelper.IsJsonObject(json);
Xml Query File Formats
<Query> <Name>Add</Name> <DataProviderType>System.Data.SqlClient</DataProviderType> <DataStoreType>Microsoft SQL Server</DataStoreType> <QueryType>Add</QueryType> <Statement>SET @CategoryID=(SELECT IsNull(MAX(CategoryID)+1,1) FROM [dbo].[Categories]) INSERT INTO [dbo].[Categories] ( [CategoryName] ,[Description] ,[Picture] ) values ( @CategoryName ,@Description ,@Picture )
</Statement> <Parameters> <Parameter> <Name>CategoryID</Name> <IsNullable>false</IsNullable> <ParameterDirection>InputOutput</ParameterDirection> <DataStoreDataType>int</DataStoreDataType> <DbType>Int32</DbType> <Precision>10</Precision> <Scale>0</Scale> <Value>1</Value> </Parameter> <Parameter> <Name>CategoryName</Name> <IsNullable>false</IsNullable> <ParameterDirection>Input</ParameterDirection> <DataStoreDataType>nvarchar</DataStoreDataType> <DbType>String</DbType> <Precision>0</Precision> <Scale>0</Scale> <Value>Beverages</Value> </Parameter> <Parameter> <Name>Description</Name> <IsNullable>true</IsNullable> <ParameterDirection>Input</ParameterDirection> <DataStoreDataType>ntext</DataStoreDataType> <DbType>String</DbType> <Precision>0</Precision> <Scale>0</Scale> <Value>Soft drinks, coffees, teas, beers, and ales</Value> </Parameter> <Parameter> <Name>Picture</Name> <IsNullable>true</IsNullable> <ParameterDirection>Input</ParameterDirection> <DataStoreDataType>image</DataStoreDataType> <DbType>Object</DbType> <Precision>0</Precision> <Scale>0</Scale> <Value>祓瑳浥䈮瑹孥�</Value> </Parameter> </Parameters> </Query>
Motivation
I needed a consistent and easy to use library in .net application.
API Reference
Tests
License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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. |
-
net7.0
- Microsoft.Data.SqlClient (>= 5.1.0)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.