I have a stored procedure that does something similar to:
SELECT a.TaskId, b.CompanyCode FROM task a JOIN company b ON b.CompanyId = a.CompanyId;
I have an object called TaskItem that has the TaskId and CompanyCode properties, but when I execute the following (which I would have assumed worked):
var masterDatabase = new Database("MasterConnectionString");
var s = PetaPoco.Sql.Builder.Append("EXEC spGetTasks @@numberOfTasks = @0", numberOfTasks);
var tasks = masterDatabase.Query<TaskItem>(s);
The problem is that the CompanyCode column does not exist in the task table, I did a trace and it seems that PetaPoco is trying to select all the properties from the task table and populating using the stored procedure.
Here is a definition of TaskItem:
public class TaskItem {
public int TaskItemId { get; set; }
public int CompanyId { get; set; }
public string CompanyCode { get; set; }
public int Status { get; set; }
}
How can I use PetaPoco to simply populate the list of task objects with the results of the stored procedure?