我的sql數據庫不包含錯誤代碼所有者,這些細節存儲在一個xml文件中當數據來自外部源時,Groupby FaultCodeOwner是否可能?C#Linq Assign Anonymous Type in GroupBy
我得到以下錯誤:無法分配無效匿名類型屬性
var query = referenceDt.AsEnumerable()
.Where(results => declarations.CaapcityIssues.Contains((results.Field<string>("FabricName"))))
.GroupBy(results => new
{
**FaultCodeOwner = faultCodeDetails.getFacultCodeOwner(results.Field<int>("FaultCode"), out owner)**
})
.OrderBy(newFaultCodes => newFaultCodes.Key.FaultCodeOnwer)
.Select(newFaultCodes => new
{
FaultCodeOwner = newFaultCodes.Key.FaultCodeOwner,
Count = newFaultCodes.Count()
});
感謝Ignaus的指導。有效。但是,我不得不刪除FaultCodeOwnerType faultCodeOwner ;.但是一旦我做了,它就像我想要的那樣工作。 – EMIE