在我的示例类中,它包含IdValues int?[]
.值来自具有Id作为关键字段的其他类.
//Database class public class SampleValues // this is a entity that i want to collect the deatil id { public int Id { get; set; } public int?[] SampleDetailIdValue { get; set; } } public class SampleDetailValues // this is the detail entity { public int Id { get; set; } } // The error code if (sampleDetails.Count > 0) { sample.IdValues = sampleDetails.Select(s => s.Id).ToArray(); // << The error occurred this line. }
错误是无法将类型隐式转换int[]
为int?[]