I have a function that receives data in a database. Below is the code.
public DataTable getAllTransaction(OleDbConnection conn) { OleDbDataAdapter oleAdapter = new OleDbDataAdapter(); string query = ""; DataTable tblResult = new DataTable(); query = @"SELECT t.id AS `Transaction ID`, c.id AS `Client ID`, c.clientname AS `Client Name`, t.cashvalue AS `Cash Value`, t.amount AS `Amount`, t.transdate AS `Transaction Date`, t.remarks AS `Remarks` FROM client AS c INNER JOIN `transaction` AS t ON c.id=t.clientid"; oleAdapter.SelectCommand = new OleDbCommand(query, conn); oleAdapter.Fill(tblResult); return tblResult; }
My problem is how can I save the result set to the model (for example, I don't want to return a DataTable). Below is my model class.
Class TransactionModel { public int transID { get; set; } public int clientID { get; set; } public string clientName { get; set; } public double cashValue { get; set; } public double amout { get; set; } public DateTime transDate { get; set; } public string remarks { get; set; } }
Bryan source share