Search code examples
sqlsql-servereager-loadingsimple.data

Simple.Data Eager Load SimpleQuery object


It appears that Simple.Data will lazy load by default.

I simply want Simple.Data to query the database and put the results in an object. For example, as soon as this piece of code is executed the results from the database should be stored in employeeData and the database should not be called again:

var employeeData = db.Employee.FindAllByEmployeeId(employeeId) .Where(db.Employee.EmployeeId == 1);

How do I do this? The Simple.Data documentation only describes how to eager load joins. I do not require any joins, simply to get results from a table when I choose to. If I include this WithEmployee() it will do a left join on the Employee table and output the same data twice...


Solution

  • Figured it out... turns out I can just create a list from the output which will save the data

    eg.

    .ToList<Employee>()