Ejemplo n.º 1
0
        internal static IProjection ProcessMod(MethodCallExpression methodCallExpression)
        {
            IProjection property = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[0]).AsProjection();
            object      divisor  = ExpressionProcessor.FindValue(methodCallExpression.Arguments[1]);

            return(Projections.SqlFunction("mod", NHibernateUtil.Int32, property, Projections.Constant(divisor)));
        }
Ejemplo n.º 2
0
        internal static IProjection ProcessCoalesce(MethodCallExpression methodCallExpression)
        {
            IProjection property             = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[0]).AsProjection();
            object      replaceValueIfIsNull = ExpressionProcessor.FindValue(methodCallExpression.Arguments[1]);

            return(Projections.SqlFunction("coalesce", NHibernateUtil.Object, property, Projections.Constant(replaceValueIfIsNull)));
        }
Ejemplo n.º 3
0
        internal static IProjection ProcessCharIndex(MethodCallExpression methodCallExpression)
        {
            IProjection property      = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[0]).AsProjection();
            object      theChar       = ExpressionProcessor.FindValue(methodCallExpression.Arguments[1]);
            object      startLocation = ExpressionProcessor.FindValue(methodCallExpression.Arguments[2]);

            return(Projections.SqlFunction("locate", NHibernateUtil.String, Projections.Constant(theChar), property, Projections.Constant(startLocation)));
        }
Ejemplo n.º 4
0
        internal static IProjection ProcessSubstr(MethodCallExpression methodCallExpression)
        {
            IProjection property   = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[0]).AsProjection();
            object      startIndex = ExpressionProcessor.FindValue(methodCallExpression.Arguments[1]);
            object      length     = ExpressionProcessor.FindValue(methodCallExpression.Arguments[2]);

            return(Projections.SqlFunction("substring", NHibernateUtil.String, property, Projections.Constant(startIndex), Projections.Constant(length)));
        }
Ejemplo n.º 5
0
        internal static IProjection ProcessSubstr(MethodCallExpression methodCallExpression)
        {
            IProjection property   = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[0]).AsProjection();
            var         startIndex = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[1]);
            var         length     = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[2]);

            return(Projections.SqlFunction("substring", NHibernateUtil.String, property, startIndex.AsProjection(), length.AsProjection()));
        }
Ejemplo n.º 6
0
        internal static IProjection ProcessConcat(MethodCallExpression methodCallExpression)
        {
            NewArrayExpression args = (NewArrayExpression)methodCallExpression.Arguments[0];

            IProjection[] projections = new IProjection[args.Expressions.Count];

            for (var i = 0; i < args.Expressions.Count; i++)
            {
                projections[i] = ExpressionProcessor.FindMemberProjection(args.Expressions[i]).AsProjection();
            }

            return(Projections.SqlFunction("concat", NHibernateUtil.String, projections));
        }
Ejemplo n.º 7
0
        internal static IProjection ProcessRound(MethodCallExpression methodCallExpression)
        {
            IProjection innerProjection =
                ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[0]).AsProjection();

            IProjection digitsProjection = Projections.Constant(0);

            if (methodCallExpression.Arguments.Count > 1)
            {
                digitsProjection = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[1]).AsProjection();
            }

            return(Projections.SqlFunction("round", NHibernateUtil.Double, innerProjection, digitsProjection));
        }
Ejemplo n.º 8
0
        public string GetSelectedTaskParticipants(int taskId)
        {
            using (var session = Hibernate.SessionFactory.OpenSession())
            {
                Task t = null;
                User u = null;

                var participants = session.QueryOver(() => t)
                                   .JoinAlias(() => t.Users, () => u)
                                   .Where(() => t.Id == taskId)
                                   .SelectList(l => l
                                               .Select(Pro.SqlFunction("CONCAT", SqlType.String,
                                                                       Pro.SqlFunction("SUBSTRING", SqlType.String,
                                                                                       Pro.SqlFunction("UPPER", SqlType.String, Pro.Property("u.Name")), Pro.Constant(1), Pro.Constant(1))
                                                                       ,
                                                                       Pro.SqlFunction("SUBSTRING", SqlType.String,
                                                                                       Pro.SqlFunction("UPPER", SqlType.String, Pro.Property("u.Surname")), Pro.Constant(1), Pro.Constant(1))
                                                                       )))
                                   .List <string>();

                return(string.Join(", ", participants.OrderBy(s => s)));
            }
        }
Ejemplo n.º 9
0
        private static IProjection SqlFunction(string name, IType type, System.Linq.Expressions.Expression projection)
        {
            IProjection property = ExpressionProcessor.FindMemberProjection(projection).AsProjection();

            return(Projections.SqlFunction(name, type, property));
        }
Ejemplo n.º 10
0
        internal static IProjection ProcessDay(System.Linq.Expressions.Expression expression)
        {
            IProjection property = ExpressionProcessor.FindMemberProjection(expression).AsProjection();

            return(Projections.SqlFunction("day", NHibernateUtil.Int32, property));
        }
Ejemplo n.º 11
0
        internal static IProjection ProcessBitLength(MethodCallExpression methodCallExpression)
        {
            IProjection property = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[0]).AsProjection();

            return(Projections.SqlFunction("bit_length", NHibernateUtil.String, property));
        }
Ejemplo n.º 12
0
        internal static IProjection ProcessDoubleAbs(MethodCallExpression methodCallExpression)
        {
            IProjection property = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[0]).AsProjection();

            return(Projections.SqlFunction("abs", NHibernateUtil.Double, property));
        }
Ejemplo n.º 13
0
        internal static IProjection ProcessMinutePart(MethodCallExpression methodCallExpression)
        {
            IProjection property = ExpressionProcessor.FindMemberProjection(methodCallExpression.Arguments[0]).AsProjection();

            return(Projections.SqlFunction("minute", NHibernateUtil.Int32, property));
        }