我有這個錯誤:匿名類型不能有多個具有相同名稱的屬性。是否可以用別名解決,即,是否存在別名LINQ匿名類型和多個屬性
var device_query = from d in DevicesEntities.device
join dt in DevicesEntities.devicetype on d.DeviceTypeId equals dt.Id
join l in DevicesEntities.location on d.Id equals l.DeviceId
join loc in DevicesEntities.locationname on l.LocationNameId equals loc.Id
where l.DeviceId == d.Id
select new {
d.Id,
d.DeviceTypeId,
d.SerialNumber,
d.FirmwareRev,
d.ProductionDate,
d.ReparationDate,
d.DateOfLastCalibration,
d.DateOfLastCalibrationCheck,
d.CalCertificateFile,
d.Notes,
d.TestReportFile,
d.WarrantyFile,
d.CertificateOfOriginFile,
d.QCPermissionFile,
d.Reserved,
d.ReservedFor,
d.Weight,
d.Price,
d.SoftwareVersion,
dt.Name,
dt.ArticleNumber,
dt.Type,
l.StartDate, //AS LastStartDate,
l.LocationNameId,
loc.Name //in this line I have problem
};
@ognjenb - 我不知道你在問什麼。確實,匿名類型不能具有多個具有相同名稱的屬性。但你如何創建這種類型的實例?你問是否LINQ會自動創建一個別名?如果你有一些示例代碼,它會有所幫助。謝謝。 – 2010-04-28 08:50:09