If you only need two columns from the database, don't bother with POCOs. Use dynamic:
var d = masterDatabase.Query<dynamic>("Exec spGetTasks @@numberOfTasks = @0", numberOfTasks);
var result = d.Select(item => new Tuple<int, string>(item.TaskId, item.CompanyCode)).ToList();
otherwise the POCO that you are using to query database, i.e. TaskItem
need to have a public property for each column name returned by the query.
UPDATE
Now that you've posted definition of TaskItem
I see that you have all the properties that you need on it. In theory it is enough to have a public property with the exact same name as the returned column for it to be populated. So in your case since query returns column CompanyCode
, the appropriate property should be populated on the TaskItem
. In case the property name differs, you can map it by decorating it with [Column]
attribute
[Column("NameOfTheColumn")]
public string CompanyCode { get; set; }
If for some reason CompanyCode
still remains not populated, the issue is with the query. Make sure that it returns appropriate results.