Looking for something specific?
  Home
Home
Articles
Page Tag-Cloud
  Software
Software Tag-Cloud
Building from Source
Open Source Definition
All Software
  Popular Tags
Legacy
C Plus Plus
Source Code
Class
Cryptography
  Members
Login
Web-Email
Notable Members
  Official
Our Company
Copyright Information
Software EULA
GPL EULA
LGPL Eula
Pre-Release EULA
Privacy Policy
  Support
Make Contact
 
NTDLS.SqlManagedConnectivity
Downloads   0
User Rating   (Rate)
Last Updated   12/5/2023
License   MIT License
- Download -
View all Releases
Recommended Release
Version   1.2.1
Date   12/5/2023
Status   Stable Stable software is believed to be stable and ready for production use.

This software is open source. You can obtain the latest source code from the GitHub repository or browse the releases for the source code associated with a specific release. If you make any changes which you feel improves this application, please let us know via our Contact Page.

NTDLS.SqlManagedConnectivity

?? Be sure to check out the NuGet pacakge: https://www.nuget.org/packages/NTDLS.SqlManagedConnectivity

Wraps a native SQL Server connection, allows for easy field/value enumeration and manages cleanup.

Simple example:

In this example we are opening a connection to the local SQL Server (".") and the database ("Dummyload"), then selecting all rows and columns from the table [Test]. This demonstrates how we can enumaerate the fields and their types as well as the rows and their values with several options for conversion.

using (var connection = new SqlManagedConnection(".", "Dummyload"))
{
    using (var reader = connection.ExecuteQuery("SELECT * FROM Test WHERE Account <> @Account", new { Account = 4104 }))
    {
        //Loop through all fields:
        foreach (var field in reader.Fields)
        {
            Console.WriteLine($"Field: '{field.Name}', Data Type: '{field.DataTypeName}', Type: '{field.Type.Name}'");
        }

        //Loop though all rows:
        foreach (var row in reader)
        {
            //Loop though all values in the row:
            foreach (var value in row)
            {
                Console.WriteLine($"{value.Field.Name} -> '{value.Value.ToString()?.Trim()}'");
            }

            var doublePercentTaxable = row.AsDouble("PercentTaxable");
            var decimalPercentTaxable = row.AsDecimal("OriginalAmount");
            var stringPercentTaxable = row.AsString("OriginalAmount");
            var intPercentTaxable = row.AsInt("OriginalAmount");
        }
    }
}

License

Apache-2.0


Recent Releases:
 1.2.1    1.2.0    1.0.0  

Tags:
 Dapper    Disposable    Managed Connectivity    Sqlserver  

No comments currently exists for this software. Why don't you add one?
First Previous Next Last 

 
Copyright © 2024 NetworkDLS.
All rights reserved.
 
Privacy Policy | Our Company | Contact