You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I'm having some trouble while trying to use ClassMapper...
My entity class:
public class Product : AuditableEntity
{
public Product() { }
public Product(int id, string name, decimal price)
{
Id = id;
Name = name;
Price = price;
}
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
}
My mapper class:
public class ProductMapper : AuditableEntityClassMapper<Product>
{
public ProductMapper()
{
Table("product");
Map(i => i.Id).Column("id").Key(KeyType.Identity);
Map(i => i.Name).Column("name_desc");
Map(i => i.Price).Column("price");
}
}
Additional class:
public abstract class AuditableEntityClassMapper<TEntity> : ClassMapper<TEntity> where TEntity : AuditableEntity
{
public AuditableEntityClassMapper()
{
Map(i => i.CreatedBy).Column("created_by");
Map(i => i.CreatedAt).Column("created_at");
Map(i => i.UpdatedBy).Column("updated_by");
Map(i => i.UpdatedAt).Column("updated_at");
}
}
The stacktrace it generates:
MySqlConnector.MySqlException (0x80004005): Unknown column 'y_1.Name' in 'field list'
at MySqlConnector.Core.ResultSet.ReadResultSetHeaderAsync(IOBehavior ioBehavior) in /_/src/MySqlConnector/Core/ResultSet.cs:line 43
at MySqlConnector.MySqlDataReader.ActivateResultSet(CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 130
It seems like it's ignoring the .Column() method in class mapper and it's generating the SQL sentence based on the class attributes. There's an example in stacktrace, with "Name" and "name_desc". But the same error happens with "CreatedAt" and "created_at", "UpdatedBy" and "updated_by", etc.
The text was updated successfully, but these errors were encountered:
Hello. I'm having some trouble while trying to use ClassMapper...
My entity class:
My mapper class:
Additional class:
The stacktrace it generates:
It seems like it's ignoring the .Column() method in class mapper and it's generating the SQL sentence based on the class attributes. There's an example in stacktrace, with "Name" and "name_desc". But the same error happens with "CreatedAt" and "created_at", "UpdatedBy" and "updated_by", etc.
The text was updated successfully, but these errors were encountered: