Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sqlContext">Sql语句上下文</param>
        /// <param name="condition"></param>
        /// <param name="orderByBuilder"></param>
        /// <param name="afterLoadAction"></param>
        /// <param name="action"></param>
        /// <param name="createNewAction"></param>
        /// <param name="tableName"></param>
        /// <param name="mappings"></param>
        public void RegisterLoadByBuilderInContext(SqlContextItem sqlContext, string condition,
                                                   OrderBySqlClauseBuilder orderByBuilder,
                                                   Action <TCollection> afterLoadAction,
                                                   Action <TCollection> action,
                                                   Func <DataRow, T> createNewAction, string tableName,
                                                   ORMappingItemCollection mappings)
        {
            if (mappings == null)
            {
                mappings = this.GetQueryMappingInfo();
            }

            string queryTableName = mappings.GetQueryTableName();

            if (tableName.IsNullOrEmpty())
            {
                tableName = queryTableName;
            }

            string sql = GetLoadSqlByBuilder(condition, orderByBuilder, queryTableName);

            this.RegisterQueryData(sqlContext, tableName, mappings, sql, (collection) =>
            {
                if (afterLoadAction != null)
                {
                    afterLoadAction(collection);
                }

                if (action != null)
                {
                    action(collection);
                }
            },
                                   createNewAction);
        }
Esempio n. 2
0
        private static string GetQueryTableName(ORMappingItemCollection mappings, DateTime timePoint)
        {
            string result = mappings.GetQueryTableName();

            if (timePoint != DateTime.MinValue)
            {
                result = mappings.TableName;
            }

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="whereAction"></param>
        /// <param name="mappings"></param>
        /// <returns></returns>
        public bool Exists(Action <WhereSqlClauseBuilder> whereAction, ORMappingItemCollection mappings = null)
        {
            whereAction.NullCheck("whereAction");

            if (mappings == null)
            {
                mappings = this.GetQueryMappingInfo();
            }

            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            whereAction(builder);
            builder.AppendTenantCode(typeof(T));

            string sql = string.Format("SELECT TOP 1 * FROM {0}", mappings.GetQueryTableName());

            if (builder.Count > 0)
            {
                sql = sql + string.Format(" WHERE {0}", builder.ToSqlString(TSqlBuilder.Instance));
            }

            return((int)DbHelper.RunSqlReturnDS(sql, GetConnectionName()).Tables[0].Rows.Count > 0);
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="orderByBuilder"></param>
        /// <param name="mappings"></param>
        /// <returns></returns>
        protected TCollection InnerLoadByBuilder(string condition, OrderBySqlClauseBuilder orderByBuilder, ORMappingItemCollection mappings)
        {
            string sql = QueryInContextBuilder <T, TCollection> .Instance.GetLoadSqlByBuilder(condition, orderByBuilder, mappings.GetQueryTableName());

            TCollection result = QueryData(sql);

            this.AfterLoad(result);

            return(result);
        }