public IRootAccessor <TClass> MapProperties <TProperty>(Expression <Func <TClass, TProperty> > expr, Expression <Func <TProperty, bool> > includeFilter = null) where TProperty : class { Visit(expr); var accessor = latestAccessor as IPropertyAccessor <TClass>; //dupes at this point if (!_rootAccessor.Properties.Contains(accessor)) { _rootAccessor.Properties.Add(accessor); } if (includeFilter != null) { if (latestAccessor is PropertyAccessor <TClass, TProperty> accessorImpl) { accessorImpl.AddFilter(includeFilter); } else { //can type checking be added here? var propertyAccessor = _rootAccessor.GetByPath(PathWalker.GetPath(expr)); dynamic dynamicAccessor = propertyAccessor; AddFilterForDynamicType(dynamicAccessor, includeFilter); } } return(_rootAccessor); }
internal static PropertyAccessor <TEntity, TProperty> Create <TEntity, TProperty> (MemberExpression exp, IPropertyAccessor parentAccessor, IRootAccessor root) where TEntity : class where TProperty : class { var pathParts = PathWalker.GetPath(exp); var newAccessor = root.GetByPath <TEntity, TProperty>(pathParts) ?? new PropertyAccessor <TEntity, TProperty>(exp, root.MappingSchema); if (parentAccessor != null && !newAccessor.Properties.Contains(parentAccessor)) { var genericParentAccessor = (IPropertyAccessor <TProperty>)parentAccessor; newAccessor.PropertiesOfTClass.Add(genericParentAccessor); } return(newAccessor); }