我无法理解一件事。假设我已经有这些编码实体:关于LINQ to SQL的简单问题
[Table(Name = "Rates")]
public class Rate
{
private EntityRef<Product> _Product;
[Column(IsPrimaryKey = true)]
public String RateID
{ get; set; }
[Column]
public String ProductID
{ get; set; }
[Column]
public Double VolumeInTons
{ get; set; }
[Column]
public Decimal Volume
{ get; set; }
[Column]
public Decimal Cost
{ get; set; }
[Column]
public UInt32 Year
{ get; set; }
[Association(Storage = "_Product", OtherKey = "ProductID")]
public Product Product
{
get { return this._Product.Entity; }
set { this._Product.Entity = value; }
}
}
而且
[Table(Name="Products")]
public class Product
{
private EntitySet<Rate> _Rates;
[Column(IsPrimaryKey= true)]
public String ProductID
{ get; set; }
[Column]
public String Name
{ get; set; }
[Column]
public String Category
{ get; set; }
[Association(Storage="_Rates", OtherKey="ProductID")]
public EntitySet<Rate> Rates
{
get { return this._Rates; }
set { this._Rates.Assign(value); }
}
}
- 我应该有一个物理数据库具有相同表定义连接(在我的应用程序中使用的DataContext)?
- 假设我已经创建了一个数据库。它应该包含相同的表定义还是
LINQ to SQL
创建它们?
看看[这个](http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.createdatabase.aspx)方法 – Reniuz 2011-05-28 06:31:53