4
在我的示例类中,它包含的IdValues是int?[]
。这些值来自另一个具有Id作为关键字段的类。不能将类型int []隐式转换为int?[]
//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?[]