TortugaResearch / Tortuga.Chain

A fluent ORM for .NET
Other
335 stars 22 forks source link

SQL Server Parameter Lengths - SqlServerDataSource.GetByColumn #499

Closed agrinei closed 1 year ago

agrinei commented 1 year ago

This is the same as #402 #414 but for SqlServerDataSource.GetByColumn

When calling SqlServerDataSource.GetByColumn it doesn't use column max length definition to set string parameters what could generate multiple query plans. It does work when we call SqlServerDataSource.From

[IT USES COLUMN DEFINITION] sqlServerDataSource.From("MY_TABLE_NAME", new { my_column_name = "COLUMN_VALUE" })

[IT DOESN'T USE COLUMN DEFINITION] sqlServerDataSource.GetByColumn("MY_TABLE_NAME", "my_column_name", "COLUMN_VALUE")

Versions tested:

Tortuga.Chain.SqlServer v.4.3.0 Tortuga.Chain.SqlServer.MDS v.4.3.0

Grauenwolf commented 1 year ago

Confirmed using test GetByColumn(string dataSourceName, DataSourceType mode)

Grauenwolf commented 1 year ago

GetByColumn calls GetByKey, so this will fix the latter as well.

Grauenwolf commented 1 year ago

This appears to also affect the Update/Delete By Key functions. Basically anything that doesn't use the ParameterBuilderCallback. So we can just create a universal CreateParameter method and move the guts of ParameterBuilderCallback into it.

Grauenwolf commented 1 year ago

All tests passing.

@agrinei Is this a current problem for you or can it wait for the next release?

agrinei commented 1 year ago

Well, my real need is SqlServerDataSource.Sql and I see how complex it is. Next release is fine.

Grauenwolf commented 1 year ago

Released in v4.4.0.

Grauenwolf commented 1 year ago

@agrinei Thank you for your help on these changes.

agrinei commented 1 year ago

I'm very thankful for your attention, @Grauenwolf

Grauenwolf commented 1 year ago

You're welcome. Feel free to reach out if you need anything else.