Skip to content

SergPavlyk/SqlTypeUtils

Repository files navigation

SqlTypeUtils

en ru

A library for validating string value conversions to specified SQL data types and mapping between .NET types, DbType, and SqlDbType.

✨ Features

  • SQL data type value validation with formatting support
  • Mapping between .NET types, DbType, and SqlDbType
  • Support for all major SQL Server data types
  • Customizable error messages with localization support
  • Advanced validation for special SQL values

📥 Installation

git clone https://github.com/SergPavlyk/SqlTypeUtils.git

🚀 Usage

SQL Value Validation

// Initialize validator with English messages
ISqlValueValidatorMsgProvider msgProvider = new SqlValValidMessEn();
SqlValueValidator validator = new SqlValueValidator(msgProvider);

// Validation example
var dateResult = validator.Validate(SqlDataType.Date, "2025.01.17");
Console.WriteLine($"Date: {dateResult.outValue}, Message: {dateResult.message}");

Type Mapping

// .NET Type -> SqlDataType
SqlDataType? sqlType = SqlTypeMapper.GetSqlDataType(typeof(byte));

// SqlDataType -> SqlDbType (for ADO.NET)
SqlDbType sqlDbType = SqlTypeMapper.GetSqlDbType(SqlDataType.BigInt);

// SqlDataType -> DbType (for Dapper/EF)
DbType dbType = SqlTypeMapper.GetDbType(SqlDataType.Money);

For a complete list of library usage examples, see Program.cs

💻 Requirements

.Net

📄 License

License

SqlTypeUtils is distributed under the Apache License 2.0. The complete license text can be found in the LICENSE.txt file.

📫 Contact

Email GitHub Issues

About

A library for validating string value conversions to specified SQL data types and mapping between .NET types, DbType, and SqlDbType

Topics

Resources

License

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Contributors

Languages