@@ -119,7 +119,7 @@ public void Map_object_type_change()
119119 //Assert
120120 Assert . True ( users . Count == 1 ) ;
121121 }
122-
122+
123123 [ Fact ]
124124 public void Map_works_with_members_from_interfaces ( )
125125 {
@@ -482,6 +482,25 @@ public void Map_orderBy_thenBy_To_Dictionary_Select_expression()
482482 Assert . True ( users [ 0 ] . Id == 11 ) ;
483483 }
484484
485+ [ Fact ]
486+ public void Map_orderBy_thenBy_To_Dictionary_Select_expression_without_generic_types ( )
487+ {
488+ //Arrange
489+ Expression < Func < IQueryable < UserModel > , IEnumerable < object > > > grouped = q => q . OrderBy ( s => s . Id ) . ThenBy ( s => s . FullName ) . ToDictionary ( kvp => kvp . Id ) . Select ( grp => new { Id = grp . Key , Name = grp . Value . FullName } ) ;
490+
491+ //Act
492+ Expression < Func < IQueryable < User > , IEnumerable < object > > > expMapped = ( Expression < Func < IQueryable < User > , IEnumerable < object > > > ) mapper . MapExpression
493+ (
494+ grouped ,
495+ typeof ( Expression < Func < IQueryable < UserModel > , IEnumerable < object > > > ) ,
496+ typeof ( Expression < Func < IQueryable < User > , IEnumerable < object > > > )
497+ ) ;
498+
499+ List < dynamic > users = expMapped . Compile ( ) . Invoke ( Users ) . ToList ( ) ;
500+
501+ Assert . True ( users [ 0 ] . Id == 11 ) ;
502+ }
503+
485504 [ Fact ]
486505 public void Map_dynamic_return_type ( )
487506 {
@@ -534,6 +553,23 @@ public void Map_parentDto_to_parent()
534553 Assert . NotNull ( expMapped ) ;
535554 }
536555
556+ [ Fact ]
557+ public void Can_map_expression_where_parent_of_member_expression_is_typeAsExpression ( )
558+ {
559+ //Arrange
560+ Parent [ ] parents = new Parent [ ]
561+ {
562+ new Parent { DateTimeObject = new DateTime ? ( new DateTime ( 2019 , 9 , 7 ) ) }
563+ } ;
564+ Expression < Func < ParentDTO , bool > > exp = p => ( p . DateTimeObject as DateTime ? ) . Value . Year . ToString ( ) == "2019" ;
565+
566+ //Act
567+ Expression < Func < Parent , bool > > expMapped = mapper . Map < Expression < Func < Parent , bool > > > ( exp ) ;
568+
569+ //Assert
570+ Assert . Equal ( 1 , parents . AsQueryable < Parent > ( ) . Count ( expMapped ) ) ;
571+ }
572+
537573 [ Fact ]
538574 public void Map_parentDto_to_parent_with_index_argument ( )
539575 {
@@ -1011,6 +1047,7 @@ public class ParentDTO
10111047 public ICollection < ChildDTO > Children { get ; set ; }
10121048 public ChildDTO Child { get ; set ; }
10131049 public DateTime DateTime { get ; set ; }
1050+ public object DateTimeObject { get ; set ; }
10141051 }
10151052
10161053 public class ChildDTO
@@ -1042,6 +1079,7 @@ public Child Child
10421079 }
10431080 }
10441081 public DateTime DateTime { get ; set ; }
1082+ public object DateTimeObject { get ; set ; }
10451083 }
10461084
10471085 public class Child
@@ -1259,7 +1297,6 @@ public OrganizationProfile()
12591297
12601298 CreateMap < EmployeeModel , EmployeeEntity > ( ) . ReverseMap ( ) ;
12611299 CreateMap < EventModel , EventEntity > ( ) . ReverseMap ( ) ;
1262- //CreateMap<EventEntity, EmployeeModel>();
12631300 }
12641301 }
12651302
0 commit comments