Here’s a short article with the requested title:
Try UkrGuru.Sql with New Optimized Results.Parse
The latest release of UkrGuru.Sql introduces a powerful enhancement: an optimized Results.Parse
method designed to streamline how developers handle SQL query results in .NET applications.
🚀 What’s New?
The new Results.Parse
method significantly improves performance and usability by:
- Faster parsing of SQL result sets into .NET objects
- Reduced memory footprint for large datasets
- Improved error handling and type safety
- Simplified syntax for cleaner, more maintainable code
📊 Benchmark Results
Method | Mean | Error | StdDev | Gen0 | Allocated |
---|---|---|---|---|---|
ResultsNew_ToStr | 541.0 ns | 66.87 ns | 3.67 ns | 0.0830 | 1096 B |
ResultsOld_ToStr | 2,195.4 ns | 177.93 ns | 9.75 ns | 0.1411 | 1872 B |
ResultsNew_FromStr | 1,021.9 ns | 85.43 ns | 4.68 ns | 0.0629 | 840 B |
ResultsOld_FromStr | 1,521.0 ns | 166.13 ns | 9.11 ns | 0.0515 | 696 B |
These results show a clear performance gain in both serialization and deserialization with the new implementation.
private static readonly object?[] _oInputs =
[
null,
DBNull.Value,
false,
true,
byte.MaxValue,
short.MaxValue,
int.MaxValue,
long.MaxValue,
float.MaxValue,
double.MaxValue,
decimal.MaxValue,
DateOnly.MaxValue,
DateTime.MaxValue,
DateTimeOffset.MaxValue,
TimeOnly.MaxValue,
TimeSpan.MaxValue,
Guid.Empty,
'A',
"AV & ASD",
Encoding.UTF8.GetBytes("AV & ASD"),
new char[] { 'A', 'V', '&', 'A', 'S', 'D' },
TestEnum.One,
//new string[] { "A", "V", "&", "A", "S", "D" },
//new NamedType { Id = 1, Name = "Test" }
];
[Benchmark]
public object?[] ResultsNew_ToStr()
{
object?[] values = new object?[_oInputs.Length];
for (var i = 0; i < values.Length; i++)
{
values[i] = ResultsNew.Parse<string?>(_oInputs[i]);
//Console.WriteLine(values[i]);
}
return values;
}
[Benchmark]
public object?[] ResultsNew_FromStr()
{
var index = 0;
object?[] values = new object?[_sInputs.Length];
values[index++] = ResultsNew.Parse<bool?>(_sInputs[0]); // null
values[index++] = ResultsNew.Parse<bool>(_sInputs[1]); // false
values[index++] = ResultsNew.Parse<bool>(_sInputs[2]); // true
values[index++] = ResultsNew.Parse<byte>(_sInputs[3]); // byte
values[index++] = ResultsNew.Parse<short>(_sInputs[4]); // short
values[index++] = ResultsNew.Parse<int>(_sInputs[5]); // int
values[index++] = ResultsNew.Parse<long>(_sInputs[6]); // long
values[index++] = ResultsNew.Parse<float>(_sInputs[7]); // float
index++; //values[index++] = ResultsNew.Parse<double>(_sInputs[8]); // double
values[index++] = ResultsNew.Parse<decimal>(_sInputs[9]); // decimal
values[index++] = ResultsNew.Parse<DateOnly>(_sInputs[10]); // DateOnly
values[index++] = ResultsNew.Parse<DateTime>(_sInputs[11]); // DateTime
values[index++] = ResultsNew.Parse<DateTimeOffset>(_sInputs[12]); // DateTime
values[index++] = ResultsNew.Parse<TimeOnly>(_sInputs[13]); // TimeOnly
values[index++] = ResultsNew.Parse<TimeSpan>(_sInputs[14]); // TimeOnly
values[index++] = ResultsNew.Parse<Guid>(_sInputs[15]); // Guid
values[index++] = ResultsNew.Parse<char>(_sInputs[16]); // char
values[index++] = ResultsNew.Parse<string>(_sInputs[17]); // string
values[index++] = ResultsNew.Parse<byte[]>(_sInputs[18]); // byte[]
values[index++] = ResultsNew.Parse<char[]>(_sInputs[19]); // char[]
values[index++] = ResultsNew.Parse<TestEnum>(_sInputs[20]); // enum
//values[index++] = ResultsNew.Parse<string[]>(_sInputs[21]); // string[]
//values[index++] = ResultsNew.Parse<NamedType>(_sInputs[22]);
//for (var i = 0; i < values.Length; i++)
//{
// Console.WriteLine(values[i]);
//}
return values;
}
🛠️ Why It Matters
Whether you're building APIs, background services, or data-driven applications, the optimized Results.Parse
helps you:
- Minimize boilerplate code
- Improve application responsiveness
- Focus more on business logic and less on data plumbing
📦 Ready to Explore?
Check out the package on NuGet and start building smarter, faster, and cleaner SQL-powered .NET apps today.
Would you like this article formatted for a blog post, social media, or a README file?
Top comments (0)