henkmollema / Dommel

CRUD operations with Dapper made simple.
MIT License
611 stars 99 forks source link

Nuget 2.4.0 package issue #274

Closed DanieleSky closed 2 years ago

DanieleSky commented 2 years ago

Hi Henk, I found an issue with the package 2.4.0. I have this mapping:

public LinguaMap()
{
    ToTable("tppLingue");
    Map(u => u.Id).ToColumn("IDLingua").IsKey().IsIdentity();
    Map(u => u.Descrizione).ToColumn("DSLingua");
    Map(u => u.Annullato).ToColumn("Annullato");
    Map(u => u.ISOCode).ToColumn("ISOCode");
}

if I do:

LinguaEntity linguaEntity = new LinguaEntity();
linguaEntity.ISOCode = "it";
Connection.Select(l => l.ISOCode == linguaEntity.ISOCode, transaction: Transaction);

the translation of SQL is

2021-12-09 17:01:56,391 [.NET Long Running Task] INFO  string - Selected SQL Builder 'SqlServerSqlBuilder' for connection type 'SqlConnection'
2021-12-09 17:01:56,457 [.NET Long Running Task] INFO  string - Resolved table name '[tppLingue]' for 'Dinamo.DataAccess.DINAMO.Lingua.LinguaEntity'
2021-12-09 17:01:56,459 [.NET Long Running Task] INFO  string - Selected SQL Builder 'SqlServerSqlBuilder' for connection type 'SqlConnection'
2021-12-09 17:01:56,463 [.NET Long Running Task] INFO  string - Resolved column name '[ISOCode]' for 'System.String ISOCode'
2021-12-09 17:01:56,468 [.NET Long Running Task] INFO  string - Select<LinguaEntity>: select * from [tppLingue] where ([ISOCode] = it)

The select is without parameters but with the value of the property.

If i try so

string ISOCode = "it";
Connection.Select(l => l.ISOCode == ISOCode, transaction: Transaction);

all works.

With version 2.3.3 the first and second examples works.

I tried to perform test with project Dommel.IntegrationTest and all works as expected:

[Theory]
[ClassData(typeof(DatabaseTestData))]
public async Task Select_WhereObject(DatabaseDriver database)
{
    Product product = new Product();
    product.Name = "Chai";
    using var con = database.GetConnection();
    var products = await con.SelectAsync<Product>(p => p.Name == product.Name);

    Assert.NotEmpty(products);
    Assert.All(products, p => Assert.StartsWith(product.Name, p.Name));
}

I think the version of NuGet package has some trouble.

henkmollema commented 2 years ago

@DanieleSky can you check if this is fixed in v3.0?

DanieleSky commented 2 years ago

Hi @henkmollema now both SELECT works as expected. Thanks!