2012-01-20 2 views
0

私のシステム(C#、MVC、MSSQL、Entityフレームワーク)では、従業員クラスの従業員休暇資格のための辞書があります。辞書MVCエンティティフレームワークからデータをDBに追加

public Dictionary<string, EmployeeLeaveEntitlement> LeaveEntitlementDetails { get; internal set; } 

EmployeeLeaveEntitlementクラス以下のように、何が必要

/// <summary> 
    /// Gets or sets the type of the leave. 
    /// </summary> 
    /// <value>The type of the leave.</value> 
    public string LeaveType { get; set; } 

    /// <summary> 
    /// Gets or sets the entitlement. 
    /// </summary> 
    /// <value>The entitlement.</value> 
    public double Entitlement { get; set; } 

    /// <summary> 
    /// Gets or sets the availed count. 
    /// </summary> 
    /// <value>The availed count.</value> 
    public double AvailedCount { get; set; } 

が、私はすでに従業員のためのコンテキストを作成し
、システムにデータベースを接続し、ある

public DbSet<Employee> Employees { get; set; }  

私は実行システムはデータベースを作成しますが、Leave Entitlementのテーブルやカラムはありません.Dのデータベースにデータを追加する方法はありますか辞書?

ヘルプme

ありがとうございました。

答えて

2

ディクショナリタイプをEntity Frameworkにマップすることはできません。

私はあなたが辞書のキーによって何を表しているかわかりませんが、あなたはEmployeeEmployeeLeaveEntitlementと辞書キーのキーで新しい中間エンティティを作成し、Employeeクラスで、コレクションとしてこれをマッピングすることができ

public class Foo 
{ 
    [Key] 
    public string DictionaryKey { get; set; } 

    public string EmployeeId { get; set; } 

    public string EmployeeLeaveEntitlementId { get; set; } 

} 

public class Employee 
{ 
    // other properties 

    public ICollection<Foo> Foos { get; set; }  
} 
+0

Ohhh Great..Erangaありがとう – iJay

関連する問題