Esempio n. 1
0
        internal static Expression GetEntrySetProjection(EntryObjects.EntrySet entrySet)
        {
            Type   type       = ((IQueryable)entrySet).ElementType;
            string filterType = type.AssertGetAttribute <System.DirectoryServices.Linq.Attributes.DirectoryTypeAttribute>().Name;

            List <MemberBinding>           bindings   = new List <MemberBinding>();
            List <LdapAttributeExpression> attributes = new List <LdapAttributeExpression>();

            foreach (MemberInfo memberInfo in GetMappedMembers(type))
            {
                string attributeName = GetAttributeName(memberInfo);
                Type   memberType    = GetMemberType(memberInfo);

                //	if (property.CanWrite && result.Properties.Contains(attributeName))
                var attributeExpression = new LdapAttributeExpression(memberType, attributeName);
                bindings.Add(Expression.Bind(memberInfo, attributeExpression));
                attributes.Add(attributeExpression);
            }

            Expression projector = Expression.MemberInit(Expression.New(type), bindings);

            Type resultType = (typeof(IEnumerable <>).MakeGenericType(type));

            // Set the filter to include the object class
            Expression filter = Expression.Equal(
                new LdapAttributeExpression(typeof(string), "ObjectClass"),
                Expression.Constant(filterType)
                );
            DirectoryEntry searchRoot = entrySet.RootEntry;
            SearchScope    scope      = SearchScope.Subtree;

            if (entrySet.Scope.HasValue)
            {
                scope = entrySet.Scope.Value;
            }

            return(new ProjectionExpression(
                       new DirectorySearcherExpression(
                           resultType,
                           searchRoot,
                           attributes,
                           filter,
                           scope,
                           null,
                           null,
                           null
                           ),
                       projector,
                       null
                       ));
        }
Esempio n. 2
0
        protected override Expression VisitAttribute(LdapAttributeExpression node)
        {
            var getattributemethod = getattributemethodgenericness.MakeGenericMethod(node.Type);

            return(Expression.Call(getattributemethod, _parameterExpression, Expression.Constant(node.Name)));
        }
Esempio n. 3
0
 protected override Expression VisitAttribute(LdapAttributeExpression node)
 {
     _sb.Append(node.Name);
     return(node);
 }
 protected virtual Expression VisitAttribute(LdapAttributeExpression node)
 {
     return(node);
 }