Last post May 13, 2011 04:44 AM by Jonathan Shen – MSFT
May 05, 2011 09:07 AM|tarunmangla|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 04:44 AM|Jonathan Shen – MSFT|LINK
What's your issue going now?