I have two classes as User and Country. User class is having a property which is object of Country. User database table is having a CountryID column.
While Retrieving User Data as Objects it gives below error:
Invalid cast from 'System.Int32' to 'country'
which is true because data table is having int and class is expecting Object of country.
Below is the menthod which I am using:
public static IEnumerable<User> GetAllUsers()
IEnumerable<User> userData = null;
IRowMapper<User> mapper = MapBuilder<User>.BuildAllProperties();
Database Db = DatabaseFactory.CreateDatabase();
// Create a stored procedure accessor that uses this output mapper
var accessor = Db.CreateSprocAccessor("GetAllUsers", mapper);
// Execute the accessor to obtain the result
View Complete Post