名称 'devicetypes' 不在 'equals' 右侧的范围内。考虑交换 'equals' 两边的表达式

The name 'devicetypes' is not in scope on the right side of 'equals'. Consider swapping the expressions on either side of 'equals'

我正在尝试从我的数据库中获取数据,但我在这一行遇到了上述错误。请帮助!!!!

join specvalue in db.Types on devicespecifications.DeviceTypeFKID equals devicetypes.DeviceTypeID

我试过切换等号,但没用。请帮忙

List<DeviceDetails> devicedetails = (
                                from devices in db.Device
                                join devicespecifications in db.DeviceSpecifications on devices.DeviceID equals devicespecifications.DeviceFKID 
                                join devicetypes in db.Types on devices.DeviceTypeFKID equals devicetypes.DeviceTypeID
                                join specvalue in db.Types on devicespecifications.DeviceTypeFKID equals devicetypes.DeviceTypeID // This Line is giving me the above mentioned error
                                join devicehistories in db.DeviceHistory on devices.DeviceID equals devicehistories.DeviceFKID
                                join locations in db.Locations on devices.LocationFKID equals locations.LocationID
                                join ips in db.IP on devices.DeviceID equals ips.DeviceFKID

                                where devices.DeviceID == id
                                select new DeviceDetails()
                                { 
                                  DeviceID = devices.DeviceID,
                                  DeviceName = devices.DeviceName,
                                  EntryDate = devices.EntryDate,
                                  AssignDate =  devices.AssignDate,
                                  DeviceStatus = devices.DeviceStatus.ToString(),
                                  MACAddress = devices.MACAddress,
                                  DateRepaired= devicehistories.DateRepaired,
                                  Remarks=  devicehistories.Remarks,
                                  SpecificationType = devicespecifications.DeviceTypeFKID,
                                  devicetypes.DeviceTypeID,
                                  SpecificationValue =  devicespecifications.SpecificationValue,
                                  FamilyIP =  ips.FamilyIP,
                                  ChildIP = ips.ChildIP,
                                  LocationTypeValue =  locations.LocationTypeValue,
                                  DeviceTypeValue =  devicetypes.DeviceTypeValue
                                }).ToList<DeviceDetails>();
        return devicedetails;
    }

在提到的行中:

join specvalue in db.Types on devicespecifications.DeviceTypeFKID equals devicetypes.DeviceTypeID

您再次使用 devicetypes 名称,但您应该在此行中使用 specvalue