Refresh array with any before assigning bcz EF Core

This commit is contained in:
honzapatCZ 2026-03-24 23:00:39 +01:00
parent 4f063f97f0
commit 6202224c92

View File

@ -645,8 +645,6 @@ namespace AutoMapProperty
public static string? GeneratePropertyTo(List<ClassToGenerate> otherClasses, string Key, ITypeSymbol FromType, ITypeSymbol ToType, bool nullable = true)
{
var sb = new StringBuilder();
sb.Append(Key).Append(@" =");
var concreteToType = GetConcreteType(ToType);
@ -657,6 +655,15 @@ namespace AutoMapProperty
if (concreteFromType.IsAbstract)
return null;
var sb = new StringBuilder();
if (isArray)
{
sb.Append(Key).Append(".Any(); source.");
}
sb.Append(Key).Append(@" =");
if (isArray)
{
sb.Append("(").Append(FromType).Append(@")(this.").Append(Key).Append(" != null ? ");