I am using specflow and have a simple table:
FirstName | Surname|
Bob | Dylan |
and a class as follows:
public class Person{
public string FirstName {get;set;}
public string LastName {get;set;}
}
and the code i want to run is:
var people = table.CreateSet<Person>();
Question:
How do I map surname from the table to LastName in the object?
Cheers
Thanks to Andreas Willich who has said the ability to add the alias will be added in a future release.
Until then, i have looked at the signatures for the methods and it does allow you to specify a function which will allow a hard coded mapping as follows which isn't the clean solution i was looking for but it fixed what i needed it to do:
var people = table.CreateSet<Person>(ConvertMethod);
..... //return type is the same as you want and method takes a Tablerow as a parameter
public static Person ConvertMethod(TableRow row)
{
return new Person()
{
FirstName = row["firstName"],
LastName = row["surname"]
};
}