2011-10-19 4 views
0

こんにちは私はMVCアプリで税率テーブルを持っています。他のテーブルとの外部キー関係はありません。MVCルックアップテーブル

それから私は、モデルクラスの請求書を持っている:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Mvc; 
using System.ComponentModel.DataAnnotations; 

namespace VectorCheck.Models 
{ 
    public class Invoice : IEntity, IValidatableObject 
    { 
     public virtual int InvoiceId { get; set; } 

     public decimal PayableAmount 
     { 
      get 
      { 
       var taxrates = new Repository<TaxRate>(); 
       var taxrate = taxrates.Where(.....some condition.....); 
       return AQuantityOfMoney * taxrate; 
      } 
     } 
    } 
} 

だから私はここを参照してください問題は、私は私のモデルの内側に私のデータソースをインスタンス化する必要があります。良くない?

誰でも私にこの問題を解決するより良い方法を教えてもらえますか?あなたがこの方法にPayableAmountプロパティを変換し、パラメータとしてリポジトリを渡すことができ

答えて

0

public decimal GetPayableAmount(ITaxRateCalculator taxrates) 
{ 
    var taxrate = taxrates.Where(.....some condition.....); 
    return AQuantityOfMoney * taxrate; 
} 
+0

素晴らしい、おかげで、うまく動作します! – AnonyMouse

関連する問題