我正在尝试在我的域服务(VS 2010 Silverlight业务应用程序)中创建一个查询,该查询返回作为特定值出现的检查读数的结果,我的数据库设置为:
Locations
a) Inspections
b) InspectionItems
c) InspectionReadings
a) Areas
b) Inspections
c) InspectionItems
d) InspectionReadings
Run Code Online (Sandbox Code Playgroud)
因此,正如您所看到的,区域和位置下的位置有检查读数.我有一个名为StatusList的POCO:
public class StatusList
{
[Key]
[Editable(false)]
public Guid ID { get; set; }
public string LocationName { get; set; }
public DateTime LastInspectionDate { get; set; }
public string Status { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我用它来返回查询的结果:
public IQueryable<StatusList> GetLocationStatus()
{
var status = (from location in this.ObjectContext.Locations
where location.InspectionReadings.Status == value
orderby a.DateTaken
select new LocationStatusList()
{
ID = a.ID,
LocationName …Run Code Online (Sandbox Code Playgroud) c# linq-to-entities visual-studio-2010 hierarchical-data silverlight-5.0