Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 13, 2011 03:44 AM by Jonathan Shen – MSFT
May 05, 2011 08:07 AM|LINK
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 results
userData = accessor.Execute();
catch (Exception ex)
I tried using MapAllProperties, does not help. Seems being a newbie missing something.
May 13, 2011 03:44 AM|LINK
What's your issue going now?