在编写LINQ to SQL查询以优化或加速LINQ to SQL时,我们可以记住哪些常见的事情?
例如,通常,LINQ to SQL必须在每次执行查询时将LINQ查询转换为SQL; 这涉及在几个阶段中递归构成查询的表达式树.我们所做的就像使用CompiledQuery类预编译查询一样.
首先使用 Web API 2 和 EF 6.1 代码。
我正在尝试添加一个Template与现有TimePeriods和Stations.
public class Template
{
public int TemplateID { get; set; }
public string Name { get; set; }
public List<TimePeriod> TimePeriods { get; set; }
public List<Station> Stations { get; set; }
}
public class Station
{
public int StationID { get; set; }
public string Name { get; set; }
public List<Template> Templates { get; set; }
}
public class TimePeriod
{
public int …Run Code Online (Sandbox Code Playgroud)