I have a below class which represents my MySql Database table with Primary key column as 'PEOPLEID'
[Map("[PEOPLE]")]
public class CreatePeopleRecordModel
{
[Map("PEOPLEID")]
[Primary]
public Guid PeopleId { get; set; }
[Map("FIRSTNAME")]
public string FirstName { get; set; }
[Map("LASTNAME")]
public string LastName { get; set; }
}
When I call below code,
connection.Update(tableName, model);
"The primary field is not found."
I debugged the code and found that in below class getting the exception -
RepoDb.Core\RepoDb\Operations\DbConnection\Update.cs
// Variables needed
var primary = DbFieldCache.Get(connection, tableName, transaction)?.FirstOrDefault(dbField => dbField.IsPrimary);
var where = (QueryGroup)null;
// Identity the property via primary
if (primary != null)
{
var property = entity?.GetType().GetProperty(primary.Name, BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance);
if (property != null)
{
where = new QueryGroup(new QueryField(new Field(property.Name, property.PropertyType), property.GetValue(entity)));
}
else
{
throw new PrimaryFieldNotFoundException("The primary field is not found.");
}
}
The Primary key variable is resolved only based on database table column which is 'PEOPLEID', but in my class I have 'PeopleId'. It is not checking for [Primary] attribute exist in the class.
Suggest me how to solve this issue?
I have a below class which represents my MySql Database table with Primary key column as 'PEOPLEID'
When I call below code,
"The primary field is not found."
I debugged the code and found that in below class getting the exception -
RepoDb.Core\RepoDb\Operations\DbConnection\Update.cs
The Primary key variable is resolved only based on database table column which is 'PEOPLEID', but in my class I have 'PeopleId'. It is not checking for [Primary] attribute exist in the class.
Suggest me how to solve this issue?