Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance 代码首先引用了许多不带FK的类_Performance_Entity Framework_Ef Code First_Code First - Fatal编程技术网

Performance 代码首先引用了许多不带FK的类

Performance 代码首先引用了许多不带FK的类,performance,entity-framework,ef-code-first,code-first,Performance,Entity Framework,Ef Code First,Code First,我们都熟悉这一点 然而,我们有以下不适合的情况 我们有一节地理课 public abstract class Location { public decimal geoLat { get; set; } public decimal geoLng { get; set; } public string Address1 { get; set; } public string Address2 { get; set; } public string Ci

我们都熟悉这一点 然而,我们有以下不适合的情况

我们有一节地理课

public abstract class Location
{
    public decimal geoLat { get; set; }
    public decimal geoLng { get; set; }

    public string Address1 { get; set; }
    public string Address2 { get; set; }

    public string City { get; set; }
    public string State { get; set; }
    public string Zip { get; set; }        
}
我们有一个报价课

public class Quote
{
    public int QuoteId {get;set;}
    public decimal Qty {get;set;}
    public decimal SubTotal {get;set;
    //etc
}
我们想要做的是具有许多位置的属性,以便我们的MSSQL模式如下所示

引述 -报价单 -小计 -乔布拉特 -工作地点 -工作地址1 -工作地址2 -就业率 -工作状态 -工作区 -比林吉奥拉特 -比林吉奥 -计费地址1 -计费地址2 -比林市 -比林州 -比林齐普 -希平格拉特 -装船 -发货地址1 -发货地址2 -船平市 -船运国 -装运拉链

在我们的应用程序中,我们希望访问诸如myQuote.location.Address1等位置信息

当然,我们可以创建一个类似于Quote.JobLocation、Quote.BillingLocation的Fk,并使用一个单独的位置表。然而,由于许多原因,使用此类Fk的性能并不理想

我们也可以像在我的示例中一样,在Quotes表中添加列,这就是它当前的设置方式,但我们希望使用强类型Quote.BillingLocation、Quote.JobLocation等

所以问题是,我们如何实现报价表结构,将位置属性直接存储在报价表中,同时使用Quote.JobLocation等

提前感谢你的帮助

添加 [复合类型]

添加到Location类,然后添加 公共位置作业位置{get;set;} 公共位置ShippingLocation{get;set;}

在Quotes表中生成了正确的属性


谢谢@KellyEthridge

您是否考虑过将Location设置为ComplexType,并将不同的Location属性添加到Quote中?这将把不同的位置放在同一个表中作为引号。@KellyEthridge听起来好像可以工作。我会让你知道事情的进展,然后再给你回复。