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   7/3/2024
License   MIT License
- Download -
View all Releases
Recommended Release
Version   1.3.0
Date   7/3/2024
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 package: https://www.nuget.org/packages/NTDLS.SqlManagedConnectivity

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

This library is a replacement for native-style SQL Server access, if you are looking something more POCO/Dapper, then check out the https://github.com/NTDLS/NTDLS.SqlServerDapperWrapper.

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 enumerate 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.As<string>()?.Trim()}'");
            }

                var doublePercentTaxable1 = row.Value<double>("PercentTaxable");
                var decimalPercentTaxable1 = row.Value<decimal>("OriginalAmount");
                var stringPercentTaxable1 = row.Value<string>("OriginalAmount");
                var intPercentTaxable1 = row.Value<int>("OriginalAmount");
        }
    }
}

License

Apache-2.0


Recent Releases:
 1.3.0    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