Exemple #1
0
        /// <summary>
        /// 按照条件加载对象
        /// </summary>
        /// <param name="loadingCondition">筛选和排序条件</param>
        /// <param name="mappings"></param>
        /// <returns>对象集合</returns>
        public TCollection Load(WhereLoadingCondition loadingCondition, ORMappingItemCollection mappings = null)
        {
            loadingCondition.NullCheck("loadingCondition");

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

            TCollection result = default(TCollection);

            PerformanceMonitorHelper.GetDefaultMonitor().WriteExecutionDuration(string.Format("Load({0})", this.GetType().FullName), () =>
            {
                loadingCondition.BuilderAction.NullCheck("whereAction");

                WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

                loadingCondition.BuilderAction(builder);

                builder.AppendTenantCode(typeof(T));

                OrderBySqlClauseBuilder orderByBuilder = null;

                if (loadingCondition.OrderByAction != null)
                {
                    orderByBuilder = new OrderBySqlClauseBuilder();

                    loadingCondition.OrderByAction(orderByBuilder);
                }

                result = this.InnerLoadByBuilder(builder.ToSqlString(TSqlBuilder.Instance), orderByBuilder, mappings);
            });

            return(result);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="loadingCondition"></param>
        /// <param name="action"></param>
        /// <param name="timePoint">时间点</param>
        /// <param name="tableName"></param>
        /// <param name="mappings"></param>
        public void LoadInContext(WhereLoadingCondition loadingCondition, Action <TCollection> action, DateTime timePoint, string tableName = null, ORMappingItemCollection mappings = null)
        {
            loadingCondition.NullCheck("loadingCondition");
            loadingCondition.BuilderAction.NullCheck("BuilderAction");

            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            loadingCondition.BuilderAction(builder);

            builder.AppendTenantCode(typeof(T));

            OrderBySqlClauseBuilder orderByBuilder = null;

            if (loadingCondition.OrderByAction != null)
            {
                orderByBuilder = new OrderBySqlClauseBuilder();

                loadingCondition.OrderByAction(orderByBuilder);
            }

            this.RegisterLoadByBuilderInContext(builder.ToSqlString(TSqlBuilder.Instance), orderByBuilder, action, timePoint, tableName, mappings);
        }