我要实现的是每天计算利息[DailyLoanCalculation],并在月底获得每个帐户的总计,并保存在[总利息]表中。每个月都会发生同样的事情
我有一个表DailyLoanCalculation,其中每天的每一天都要计算我的每日利息。我已经能够实现这一目标。
DailyLoanCalculation table
Day Account No Loan interest Amount Per day
1 12345 3000 150
1 23456 1000 50
1 43567 2500 125
2 12345 3000 150
2 23456 1000 50
2 43567 2500 125
Total-Interest Table
Day Account No Loan Total Interest Total
30 12345 3000 300 3300
30 23456 1000 100 1100
30 43567 2500 250 2750
现在要实现[总利息]中的问题。 这是我一直努力但无法前进的东西
//Calculate the EndOfMonthDailyInterestCalculation
public void EndOfMonthDailyInterestCalculation()
{
IEnumerable<DailyInterest> loans = null;
using (var conn = new SqlConnection(ConnectionString))
{
conn.Open();
loans = conn.Query<DailyInterest>("Select * from DailyInterest where BackgroundMonthly is Null");
if (loans.Count() == 0)
{
return;
}
var TotalEachLoanInterest = loans.GroupBy(x => x.LoanAccountNo).Select(g =>g.Sum(x=>x.AmountPerDay));
**//I can go further at this point**
if (TotalEachLoanInterest.Count() == 0)
{
return;
}
else
{
foreach (var loan in loans)
{
var SumOfInteretForTheMonth = loan.
var markDailyAsCalculated = new
{
amountPerday = loan.AmountPerDay
};
}
}
}
}
如果有更好的解决方法,请帮帮我 谢谢