コード例 #1
0
        private void GetVMatrix(SqlExp <Matrix> sqlMain)
        {
            //sqlMain =>
            //{
            //main select
            sqlMain.Select(p => p.Id);
            sqlMain.Select(p => p.Name);
            sqlMain.Select(p => p.Code);
            sqlMain.Select(p => p.WordLength);
            sqlMain.Select(p => p.SyncWord1);
            sqlMain.Select(p => p.SyncWord2);
            sqlMain.Select(p => p.SyncWord3);
            sqlMain.Select(p => p.SyncWord4);
            sqlMain.Select(p => p.FrameCounterStartWith);
            sqlMain.Select(p => p.Activated);
            sqlMain.Select(p => p.IsDeleted);
            sqlMain.Select(p => p.OriginalData);
            sqlMain.Select(p => p.Description);
            sqlMain.Select(p => p.CreatedTime);
            sqlMain.Select(p => p.LastUpdatedTime);


            //sub query parameter indo
            var sqlInfo =
                sqlMain.JoinSubQuery <VEParametersInfo, string>(sql =>
            {
                //sub query parameter child
                var sqlchild = sql.JoinSubQuery <VEParameterChild, string>(sql2 =>
                {
                    sql2.Select(p => p.ParameterId);
                    sql2.Count <VEParameterChild>(p => p.Id, v => v.Frequency);
                    sql2.Where(v => v.PartIndex == 1);
                    sql2.GroupBy(p => p.ParameterId);
                }, p => p.ParameterId,
                                                                           v => v.ParameterId, JoinType.InnerJoin);
                //selection and other

                sql.Select(p => p.MatrixId);
                sql.Count <VEParametersInfo>(p => p.Id, v => v.ParameterCount);
                sql.MaxSubQuery <VEParameterChild>(sqlchild, p => p.Frequency, v => v.MaxFrequency);

                sql.GroupBy(p => p.MatrixId);
            }, p => p.Id, v => v.MatrixId, JoinType.LeftOuterJoin);

            sqlMain.SelectSubQuery <VMatrix>(sqlInfo, p => p.ParameterCount, p => p.MaxFrequency);


            //sub query  r aircraft _matrix

            var sqlAir = sqlMain.JoinSubQuery <RelationAircraftMatrix, string>(sql =>
            {
                sql.Select(p => p.MatrixCode);
                sql.Count <VMatrix>(v => v.Id, p => p.RelationAircraftCount);
                sql.Where(p => p.IsDeleted == false);
                sql.GroupBy(p => p.MatrixCode);
            }, p => p.Code, v => v.MatrixCode, JoinType.LeftOuterJoin);

            sqlMain.SelectSubQuery <VMatrix>(sqlAir, v => v.RelationAircraftCount);

            //subquery decode process

            var sqlDecode = sqlMain.JoinSubQuery <DecodeProcess, string>(sql =>
            {
                sql.Select(p => p.MatrixCode);
                sql.Count <VMatrix>(p => p.Id, v => v.DecodeTimes);
                sql.Max <VMatrix>(p => p.CreatedTime, v => v.LastUsageDate);
                sql.GroupBy(p => p.MatrixCode);
            }, p => p.Code,
                                                                         v => v.MatrixCode, JoinType.LeftOuterJoin);

            sqlMain.SelectSubQuery <VMatrix>(sqlDecode, v => v.DecodeTimes, v => v.LastUsageDate);

            //};
        }