Guest User

Untitled

a guest
Jan 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. private static void CreateMapForEF<TDto, TEntity>()
  2. {
  3. Mapper.CreateMap<TDto, TEntity>()
  4. .ForAllMembers(o => o.Condition(ctx =>
  5. {
  6.  
  7. var members = ctx.Parent.SourceType.GetMember(ctx.MemberName); // get the MemberInfo that we are mapping
  8.  
  9. if (!members.Any())
  10. return false;
  11.  
  12. if (members.First().GetCustomAttributes(
  13. typeof (EdmRelationshipNavigationPropertyAttribute), false).Any())
  14. return false;
  15.  
  16. return members.First().GetCustomAttributes(typeof(EdmScalarPropertyAttribute), false).Any(); // determine if the Member has the EdmScalar attribute set
  17.  
  18. }));
  19. }
Add Comment
Please, Sign In to add comment