File tree Expand file tree Collapse file tree
src/AutoMapper.Collection/AutoMapper.Collection.EntityFramework Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- using System . Data . Entity ;
1+ using System ;
2+ using System . Collections ;
3+ using System . Collections . Generic ;
4+ using System . Data . Entity ;
5+ using AutoMapper . QueryableExtensions . Impl ;
26
37namespace AutoMapper . EntityFramework
48{
@@ -15,5 +19,21 @@ public static IPersistance Persist<TSource>(this DbSet<TSource> source)
1519 {
1620 return new Persistance < TSource > ( source , Mapper . Engine ) ;
1721 }
22+
23+ /// <summary>
24+ /// Non Generic call for For
25+ /// </summary>
26+ /// <typeparam name="TSource"></typeparam>
27+ /// <param name="source"></param>
28+ /// <param name="destType"></param>
29+ /// <returns></returns>
30+ public static IEnumerable For < TSource > ( this IQueryDataSourceInjection < TSource > source , Type destType )
31+ {
32+ var forMethod = source . GetType ( ) . GetMethod ( "For" ) . MakeGenericMethod ( destType ) ;
33+ var listType = typeof ( List < > ) . MakeGenericType ( destType ) ;
34+ var forResult = forMethod . Invoke ( source , new object [ ] { null } ) ;
35+ var enumeratedResult = Activator . CreateInstance ( listType , forResult ) ;
36+ return enumeratedResult as IEnumerable ;
37+ }
1838 }
1939}
You can’t perform that action at this time.
0 commit comments