You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by kwaazaar January 17, 2024
When I want to map an expression on TSource to TTarget, it makes sense that my mapping configuration defines a map from TSource to TTarget. However, it also needs a map from TTarget to TSource. Why is that?
Also, mapping a certain expression, that worked on AM v6, now gives me this error, but I have no idea how to fix this: No generic method 'Count' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.
[Fact]publicvoidCanMap(){varmapper=newAutoMapper.MapperConfiguration(cfg =>{cfg.CreateMap<SourceType,TargetType>().ReverseMap();cfg.CreateMap<SourceChildType,TargetChildType>().ReverseMap();// Same source type can map to different target types. This seems unsupported currently.cfg.CreateMap<SourceListItemType,TargetListItemType>().ReverseMap();cfg.CreateMap<SourceListItemType,TargetChildListItemType>().ReverseMap();}).CreateMapper();Expression<Func<SourceType,bool>>sourcesWithListItemsExpr= src =>src.Id!=0&&src.ItemList!=null&&src.ItemList.Any();// Sources with non-empty ItemListExpression<Func<TargetType,bool>>target1sWithListItemsExpr=mapper.MapExpression<Expression<Func<TargetType,bool>>>(sourcesWithListItemsExpr);}internalclassSourceChildType{publicintId{get;set;}publicIEnumerable<SourceListItemType>ItemList{get;set;}// Uses same type (SourceListItemType) for its itemlist as SourceType}internalclassSourceType{publicintId{get;set;}publicSourceChildTypeChild{set;get;}publicIEnumerable<SourceListItemType>ItemList{get;set;}}internalclassSourceListItemType{publicintId{get;set;}}internalclassTargetChildType{publicvirtualintId{get;set;}publicvirtualICollection<TargetChildListItemType>ItemList{get;set;}=newList<TargetChildListItemType>();}internalclassTargetChildListItemType{publicvirtualintId{get;set;}}internalclassTargetType{publicvirtualintId{get;set;}publicvirtualTargetChildTypeChild{get;set;}publicvirtualICollection<TargetListItemType>ItemList{get;set;}=newList<TargetListItemType>();}internalclassTargetListItemType{publicvirtualintId{get;set;}}
The text was updated successfully, but these errors were encountered:
Discussed in #174
Originally posted by kwaazaar January 17, 2024
When I want to map an expression on TSource to TTarget, it makes sense that my mapping configuration defines a map from TSource to TTarget. However, it also needs a map from TTarget to TSource. Why is that?
Also, mapping a certain expression, that worked on AM v6, now gives me this error, but I have no idea how to fix this:
No generic method 'Count' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.
The text was updated successfully, but these errors were encountered: