Skip to content

Instantly share code, notes, and snippets.

@skinny
Created February 21, 2013 22:44
Show Gist options
  • Save skinny/5009097 to your computer and use it in GitHub Desktop.
Save skinny/5009097 to your computer and use it in GitHub Desktop.
public IEnumerable<GeneralLedger> GetUnprocessedEntriesForOrganizationUnit(OrganizationUnit ou)
{
using (var conn = _dapper.OpenConnection())
{
var query = string.Format(@"
SELECT GL.*, A.*, BOU.*
FROM GeneralLedger GL
INNER JOIN Accounts A ON (A.ID = GL.AccountID)
LEFT JOIN OrganizationUnits BOU ON (BOU.ID = A.BookOnOrganizationUnitID)
WHERE GL.OrganizationUnitID = @orgID
AND GL.IsProcessed = 0
", (int)FinancialPeriodStatus.Closed);
var results = conn.QueryMultiple(query, new { @orgID = ou.ID });
var records = results.Read<GeneralLedger, Account, OrganizationUnit, GeneralLedger>((gl, a, o) =>
{
a.BookOnOrganizationUnit = o;
gl.Account = a;
return gl;
}).ToList();
return records;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment