Closed liuqing19851022 closed 1 year ago
You can not cast from a base type to a derived type. There is no guarantee that TestEmpty is of type SubEntity. You can however cast to the base class as follows:
SubEntity subEntity = new SubEntity();
TestEmpty testEmpty = subEntity.Adapt<TestEmpty>();
System.InvalidCastException: Unable to cast object of type 'Sample.AspNetCore.Models.TestEmpty' to type 'Sample.AspNetCore.Models.SubEntity'. at lambda_method12(Closure , Object )