public VoteInfo PopulateVote(System.Data.IDataRecord reader) { VoteInfo voteInfo = new VoteInfo(); Type type = voteInfo.GetType(); for (int i = 0; i < reader.FieldCount; i++) { string name = reader.GetName(i); PropertyInfo property = type.GetProperty(name); if (property != null) { property.SetValue(voteInfo, reader[i], null); } } return(voteInfo); }