0
我想要做一個基本的lnq到使用屬性的sql外鍵映射。這應該很簡單,但我很難在網上找到體面的信息。我哪裏錯了?Linq到SQL外鍵映射
舉例來說,你有一個名爲User的用UserId,FirstName,LastName,Location的類。位置稱爲位置
位置類有LocationId,StreetNum,名稱,郊區
如何映射與LINQ to SQL的對象?
這裏就是我試圖
[Column]
public int LocationId { get; set; }
private EntityRef<Location> _location;
[Required(ErrorMessage = "Please enter your suburb")]
[System.Data.Linq.Mapping.Association(Storage = "_location", ThisKey = "LocationId", IsForeignKey = true)]
public Location Location
{
get { return this._location.Entity; }
set { this._location.Entity = value;
LocationId = value.LocationId;
}
}
我得到這個錯誤: 空值不能分配給具有類型System.Double的成員這是一個非空的值類型。
任何人都可以幫忙嗎?
嘗試使用數據庫中定義的設計器自動生成代碼,並查看代碼生成器吐出的內容。 – Steven 2011-01-11 10:35:50