Skip to content

Commit 7210ccb

Browse files
committed
fix: removes support to collection in apply to
1 parent db14501 commit 7210ccb

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

ProjectR.Sample/Domain/Domain.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace ProjectR.Sample.Domain
66
{
7-
public abstract class BaseEntity
7+
public abstract class BaseEntity<TId>
88
{
9-
public Guid Id { get; set; }
9+
public TId Id { get; set; }
1010
}
1111

12-
public class Category : BaseEntity
12+
public class Category : BaseEntity<Guid>
1313
{
1414
public string Name { get; set; }
1515

ProjectR/Builders/CodeBuilder.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,11 @@ private void GenerateMappingInstructions(string sourceVar, string? destVar, Mapp
241241
assignment = $"{nested.Destination.Name} = this._{GetFieldName(nested.Mapper)}.{nestedMethod}({sourceVar}.{nested.Source.Name})";
242242
break;
243243
case CollectionPropertyMapping collection:
244-
var elementMethod = GetNestedMethodName(GetCollectionElementType(collection.Source.Type), GetCollectionElementType(collection.Destination.Type), isApplyTo);
245-
assignment = $"{collection.Destination.Name} = {sourceVar}.{collection.Source.Name}?.Select(x => this._{GetFieldName(collection.ElementMapper)}.{elementMethod}(x)).ToList()";
244+
if (!isApplyTo)
245+
{
246+
var elementMethod = GetNestedMethodName(GetCollectionElementType(collection.Source.Type), GetCollectionElementType(collection.Destination.Type), isApplyTo);
247+
assignment = $"{collection.Destination.Name} = {sourceVar}.{collection.Source.Name}?.Select(x => this._{GetFieldName(collection.ElementMapper)}.{elementMethod}(x)).ToList()";
248+
}
246249
break;
247250
}
248251
if (!string.IsNullOrEmpty(assignment))

0 commit comments

Comments
 (0)