2012-03-18 11 views
0

dateTimeを処理しようとしています。 Now()を使用しているdateCreatedフィールドを作成しました。他の計算されたdateTimeフィールドを追加できますか?それは自動的に2日間追加されます。 たとえば、dateCreatedは2012年3月18日に作成されます。2012年3月20日に設定されたdateTimeの新しい値を作成したいと思います。モデルで日付を計算することは可能ですか? ここに私のコードです。ありがとう。MVC3追加日としての日付計算

public class Cart 
{ 
    [Key] 
    public int recordId { get; set; } 
    public string cartId { get; set; } 
    public int productId { get; set; } 
    public int count { get; set; } 
    public DateTime dateCreated { get; set; } 
    // Can I make startDate as adding two days with dateCreated? 
    // Is there any calculation for this? 
    //public DateTime startDate { get; set; } 
    public virtual Product Product { get; set; } 
} 

答えて

2
private DateTime _startDate; 


public DateTime StartDate 
{ 
    set { _startDate=value; } 
    get { return dateCreated.AddDays(2); } 

}