Esempio n. 1
0
        private void ParseDeleteSqlDetail(SqlStatementCollection sqlSchemata, SqlStatementCollection result, DomainModel.Spi.DomainModel domainModel,
                                          DomainModel.Spi.DomainObject domainObject, DataContext dataContext, Dictionary <string, ShardingTarget> routeInfo)
        {
            //构造SQL语句的条件
            var strategy = new DeleteSqlBuildStrategy();
            var context  = new SqlBuildingContext(domainModel, domainObject, domainObject.DataObject.DataSource.DbType, dataContext);

            context.RouteInfo = routeInfo;
            var rowSqls = new SqlStatementCollection();
            var sqls    = sqlSchemata.Where(s => s.SqlBuildingInfo.CurrentNode.ID == domainObject.ID).ToList();

            rowSqls.AddRangeClone(sqls);
            strategy.BuildTableSqlDetail(rowSqls, context);
            result.AddRange(rowSqls);

            //递归处理子对象
            if (domainObject.ChildDomainObjects.Count == 0)
            {
                return;
            }
            foreach (var childModelObject in domainObject.ChildDomainObjects)
            {
                ParseDeleteSqlDetail(sqlSchemata, result, domainModel, childModelObject, dataContext, routeInfo);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 构造查询SQL语句的主干结构
        /// </summary>
        /// <param name="dataObject">数据对象</param>
        /// <returns>查询SQL语句的主干结构</returns>
        private void ParseDeleteSqlSchema(SqlStatementCollection sqlSchemata, DomainModel.Spi.DomainModel domainModel, DomainModel.Spi.DomainObject domainObject, Dictionary<string, ShardingTarget> routeInfo, DataContext dataContext)
        {
            var selectStrategy = new DeleteSqlBuildStrategy();
            var context = new SqlBuildingContext(domainModel, domainObject, SQLBuilderUtils.GetCurrentDbType(), dataContext);
            context.RouteInfo = routeInfo;

            var nodeSqlSchemata = selectStrategy.BuildTableSqlSchema(context);
            sqlSchemata.AddRange(nodeSqlSchemata);

            //递归处理子对象
            if (domainObject.ChildDomainObjects.Count == 0) return;

            foreach (var childModelObject in domainObject.ChildDomainObjects)
            {
                ParseDeleteSqlSchema(sqlSchemata, domainModel, childModelObject, routeInfo, dataContext);
            }
        }