Exemple #1
0
        /// <summary>
        /// 查询条件
        /// </summary>
        /// <param name="sqlTable">数据库表格操作工具</param>
        /// <param name="sqlStream">SQL表达式流</param>
        /// <param name="expression">查询条件表达式</param>
        /// <param name="isCreatedIndex">是否已经创建查询索引</param>
        /// <returns></returns>
        internal static unsafe bool WriteWhere(fastCSharp.emit.sqlTable.sqlToolBase sqlTable, charStream sqlStream, Expression <Func <valueType, bool> > expression, ref bool isCreatedIndex)
        {
            if (expression == null)
            {
                return(true);
            }
            sqlStream.PrepLength(6);
            sqlStream.UnsafeAddLength(6);
            int  length                    = sqlStream.Length;
            bool logicConstantWhere        = false;
            keyValue <string, string> name = sqlTable.Client.GetWhere(expression, sqlStream, ref logicConstantWhere);

            if (length == sqlStream.Length)
            {
                sqlStream.UnsafeFreeLength(6);
                return(logicConstantWhere);
            }
            if (name.Key != null)
            {
                byte *where = (byte *)(sqlStream.Char + length);
                *(uint *)(where - sizeof(uint))     = 'e' + (' ' << 16);
                *(uint *)(where - sizeof(uint) * 2) = 'e' + ('r' << 16);
                *(uint *)(where - sizeof(uint) * 3) = 'w' + ('h' << 16);
                isCreatedIndex = true;
                sqlTable.CreateIndex(name.Key, name.Value);
            }
            return(true);
        }