在我的示例类中,它包含了一个int?[]
类型的IdValues。这些值来自于另一个类,该类具有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?[]
。