another-guy - Prosecco 1.0.1-b00006

Simplifies SQL database querying a bit

PM> Install-Package Prosecco -Version 1.0.1-b00006 -Source https://www.myget.org/F/another-guy/api/v3/index.json

Copy to clipboard

> nuget.exe install Prosecco -Version 1.0.1-b00006 -Source https://www.myget.org/F/another-guy/api/v3/index.json

Copy to clipboard

> dotnet add package Prosecco --version 1.0.1-b00006 --source https://www.myget.org/F/another-guy/api/v3/index.json

Copy to clipboard
<PackageReference Include="Prosecco" Version="1.0.1-b00006" />
Copy to clipboard
source https://www.myget.org/F/another-guy/api/v3/index.json

nuget Prosecco  ~> 1.0.1-b00006
Copy to clipboard

> choco install Prosecco --version 1.0.1-b00006 --source https://www.myget.org/F/another-guy/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "another-guy" -SourceLocation "https://www.myget.org/F/another-guy/api/v2"
Install-Module -Name "Prosecco" -RequiredVersion "1.0.1-b00006" -Repository "another-guy" -AllowPreRelease
Copy to clipboard

Synopsis

Prosecco

Simplifies SQL database querying a bit

Code Example

SqlClient creation:

var sqlClient = new SqlClient(regularConnectionString);

ExecuteNonQueryAsync:

var rowsAffected = await sqlClient.ExecuteNonQueryAsync(
	"INSERT INTO dbo.Users (Username) VALUES (@username)",
	new Dictionary<string, object>
	{
		{ "@username", "Vasile Pupkeanu" }
	});

ExecuteReaderAsync:

var userList = await sql.ExecuteReaderAsync(
	"SELECT Id, Username FROM dbo.Task WHERE Id = @id",
	new Dictionary<string, object>
	{
		{ "@id", userId },
	},
	reader =>
	{
		var result = new List<User>();
		while (reader.Read())
		{
			result.Add(new User
			{
				Id = reader.GetString(0),
				Username = reader.GetString(1)
			});
		}
		return result;
	});

ExecuteScalarAsync:

var userName = await sql.ExecuteScalarAsync(
	"SELECT Name FROM dbo.Task WHERE Id = @id",
	new Dictionary<string, object>
	{
		{ "@id", userId },
	});

ExecuteXmlReaderAsync:

var userList = await sql.ExecuteXmlReaderAsync(
	"SELECT Id, Username FROM dbo.Task WHERE Id = @id",
	new Dictionary<string, object>
	{
		{ "@id", userId },
	},
	xmlReader =>
	{
		var result = new List<User>();
		
		// populate result object from the xmlReader

		return result;
	});

Motivation

Syntax sugar is syntax sugar: it's not a necessary thing per se but it can improve code quality.

Installation

Prosecco is a available in a form of a NuGet package. Follow regular installation process to bring it to your project. https://www.nuget.org/packages/Prosecco/

Tests

Unit tests are available in Prosecco.Tests project.

License

The code is distributed under the MIT license.

Reporting an Issue

Reporting an issue, proposing a feature, or asking a question are all great ways to improve software quality.

Here are a few important things that package contributors will expect to see in a new born GitHub issue:

  • the relevant version of the package;
  • the steps to reproduce;
  • the expected result;
  • the observed result;
  • some code samples illustrating current inconveniences and/or proposed improvements.

Contributing

Contribution is the best way to improve any project!

  1. Fork it!
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

...or follow steps described in a nice fork guide by Karl Broman

  • .NETStandard 1.6
    • NETStandard.Library (>= 1.6.0)
    • Peppermint (>= 1.0.0-alpha5)
    • System.Data.SqlClient (>= 4.1.0)
  • .NETStandard 1.6: 1.6.0.0

Owners

another-guy

Authors

Igor Soloydenko

Project URL

https://github.com/another-guy/Prosecco

License

MIT

Tags

SQL,SqlClient

Info

5 total downloads
0 downloads for version 1.0.1-b00006
Download (6.61 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
1.0.1-b00006 6.61 KB Sun, 28 Aug 2016 04:19:08 GMT 0
1.0.1-b00005 6.61 KB Sat, 27 Aug 2016 21:42:06 GMT 1
1.0.1-b00004 6.61 KB Sat, 27 Aug 2016 21:38:50 GMT 1
1.0.1-b00003 6.61 KB Sun, 07 Aug 2016 22:39:48 GMT 1
1.0.1-b00002 6.61 KB Sat, 06 Aug 2016 02:10:30 GMT 2