+Demis Bellot
A question on OrmLite’s support for auto mapping {Table}{Field}
convention.
From looking at the code, it’s matching on the FieldDefinition.FieldName property (i.e. actual, possibly aliased, column name) instead of the FieldDefinition.Name property:
// Add support for auto mapping {Table}{Field}
convention
foreach (var tableDef in tableDefs)
{
var tableName = tableDef.Name;
var matchingField = tableDef.FieldDefinitionsArray
.FirstOrDefault(x => tableName + x.FieldName == fieldDef.Name);
//etc…
}
This means it won’t work in some cases e.g. if the columns have aliases containing a space.
public class User
{
public property Id { get; set; }
[Alias(“First Name”)]
public property Name { get; set; }
[Alias(“Last Name”)]
public property Surname { get; set; }
}
POCO for join result:
public class UserDetail
{
public property UserId { get; set; }
public property UserName { get; set; }
public property UserSurname { get; set; }
}
The convention will look for “User” + “First Name” == “UserName” and not find a match.
Was this your intended design?
Or should the code be changed to:
var matchingField = tableDef.FieldDefinitionsArray
.FirstOrDefault(x => tableName + x.Name == fieldDef.Name);
ok yeah that should be just the Property Names. I’ve updated it in this commit to also include Alias property names:
https://github.com/ServiceStack/ServiceStack.OrmLite/commit/92db7c7502313cc83deb0351a4433e546a7e0c22
Which is now on MyGet:
https://github.com/ServiceStack/ServiceStack/wiki/MyGet