如何使用实体框架

时间:2017-11-25 21:02:29

标签: asp.net-mvc oracle entity-framework odp.net

我需要在使用ASP.NET MVC4技术的网站和带有Oracle数据库的Entity Framework 5中实现认可的支出管理系统。

费用总结在一个由会计期间的结构确定的单据中。单据存储在数据库中。

每个结构都有一个基金来提取支出金额。 我必须,因为每一次创作都是如此:

  • 通过计算确定现金收入和支出后每张单据的现金余额(现金余额)

公式:期末余额=期初余额+收入总额 - 支出总额

如:

  • 期初余额:是支付前的余额,也是之前单据的期末余额

  • 支出总额:此单据支出的总和

  • 收据总和:以前单据的还款总额

为了保持历史平衡,我创建了一个Oracle视图:

CREATE OR REPLACE FORCE VIEW BALANCEVIEW
(
   sum_disbursements, 
   sum_receipts,
   balance_opening,
   balance_closing,
   Date_slip,
)
AS
   SELECT
       SUM(actu_slip.disbursements) as sum_disbursements, 
       SUM(priv_slip.disbursements) as sum_receipts,
       priv_slip.balance as balance_opening,--how i can store opening balance in database
       priv_slip.balance + sum(actu_slip.disbursements)- sum(priv_slip.disbursements) as balance_closing,                 
       actu_slip.date_slip
   FROM 
       slip as actu_slip, --actual slip
       JOIN slip as priv_slip
       ON actu_slip.slipID = priv_slip.ActualSlipId --previous slip

以下是我的实体:

     public class slip
     {
        public int Id {get; set;}
        public string SlipNumber {get; set;}
        public string AccountingPeriode {get; set;}

        [DatabaseGenerated(DatebaseGenerated.Computed)]
        public double TotalExpenses 
        {
          get {
           return expenses.sum(ex=>ex.Debit);
         }
       }

       [DatabaseGenerated(DatabaseGenerated.Computed)]
       public double OpeningBalance {get; set;}

       [DatabaseGenerated(DatabaseGenerated.Computed)]
       public double ClosingBalance {get; set;}

       public private ICollection<expense> expenses {get; set;}
   }

   //entity class expense
   public class Expense
   {
       public int Id {get; set;}
       public string Debit {get; set;}
       public Datetime ExpenseDate {get; set;}
       public string Wording  {get; set;}
       public int SlipId {get; set;}
       public private Slip slip {get; set;}
   }

首先在Entity Framework代码中展示balance属性还是模拟第一个类,有没有比这更好的方法?

由于余额是一个计算属性,所以计算出一个好主意的开头余额?当用户在第一张纸的创建表单视图中输入时,我如何以及在哪里第一次存储期初余额?有没有比这更好的方法?

拜托,你有什么建议吗?如果你帮助了我,我将不胜感激。

很快再见

0 个答案:

没有答案