Beispiel #1
0
        private static void Setup_SelectByKeyValueArray(SpecialLinqCommand command)
        {
            var member         = command.Key.ExpandedKeyMembers[0].Member;
            var listType       = typeof(IList <>).MakeGenericType(member.DataType);
            var listPrm        = Expression.Parameter(listType, "@list");
            var entType        = command.Key.Entity.EntityType;
            var pred           = ExpressionMaker.MakeListContainsPredicate(member, listPrm);
            var entSet         = member.Entity.EntitySetConstant;
            var entSetFiltered = ExpressionMaker.MakeCallWhere(entSet, pred);
            var entSetOrdered  = ExpressionMaker.AddOrderBy(entSetFiltered, command.OrderBy);

            command.Lambda = Expression.Lambda(entSetOrdered, listPrm);
        }
Beispiel #2
0
        // Setup methods

        private static void Setup_SelectByKey(SpecialLinqCommand command)
        {
            var key      = command.Key;
            var lockType = command.LockType;
            var orderBy  = command.OrderBy;

            var entType = key.Entity.EntityType;
            var prms    = key.ExpandedKeyMembers.Select(m => Expression.Parameter(m.Member.DataType, "@" + m.Member.MemberName)).ToArray();
            var pred    = ExpressionMaker.MakeKeyPredicate(key, prms);
            var entSet  = (lockType == LockType.None) ? key.Entity.EntitySetConstant
                                               : ExpressionMaker.MakeEntitySetConstant(entType, lockType);
            var entSetFiltered = ExpressionMaker.MakeCallWhere(entSet, pred);
            var entSetOrdered  = ExpressionMaker.AddOrderBy(entSetFiltered, command.OrderBy);
            var lambdaExpr     = Expression.Lambda(entSetOrdered, prms);

            command.Lambda = lambdaExpr;
        }
Beispiel #3
0
        public static Expression AddOrderByManyToMany(Expression linkEntSet, EntityInfo linkEnt, EntityMemberInfo targetProp,
                                                      List <EntityKeyMemberInfo> orderBy)
        {
            if (orderBy == null || orderBy.Count == 0)
            {
                return(linkEntSet);
            }
            var entSetOrdered = linkEntSet;

            foreach (var km in orderBy)
            {
                if (km.Member.Entity == linkEnt)
                {
                    entSetOrdered = ExpressionMaker.AddOrderBy(entSetOrdered, km.Member, km.Desc);
                }
                else
                {
                    entSetOrdered = ExpressionMaker.AddOrderBy(entSetOrdered, km.Member, km.Desc, targetProp);
                }
            }
            return(entSetOrdered);
        }