protected override void VisitInsert(InsertBuilder item)
        {
            var visitor = new CreateRequestBuilderVisitor(Parameters, CrmMetadataProvider, Settings);
            IVisitableBuilder visitable = item;

            visitable.Accept(visitor);
            SetOperation(visitor.GetCommand());
        }
Exemplo n.º 2
0
        public void ShouldCreateAInsertQuery()
        {
            var builder = new InsertBuilder();
            builder.Insert(new Person {Name = "Jony Tek"});

            var query = builder.ToString().Replace(Environment.NewLine, "");

            query.Should().Be("INSERT INTO [dbo].[Person]([Name])VALUES('Jony Tek')");
        }
        public static bool DbInsert(this TEarthworkBlock entity, DbSession session)
        {
            var           query   = session.GetDbQueryBuilder();
            InsertBuilder builder = new InsertBuilder();

            if (entity.Segregation == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Segregation));
            }
            if (entity.Segregation.Length > 36)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.Segregation), entity.Segregation.Length, 36));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.Segregation, entity.Segregation));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.IssueDateTime, entity.IssueDateTime));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.Id, entity.Id));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.Indexer, entity.Indexer));
            if (entity.Name == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Name));
            }
            if (entity.Name.Length > 100)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.Name), entity.Name.Length, 100));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.Name, entity.Name));
            if (entity.Description == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Description));
            }
            if (entity.Description.Length > 1000)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.Description), entity.Description.Length, 1000));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.Description, entity.Description));
            if (entity.CPSettings == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.CPSettings));
            }
            if (entity.CPSettings.Length > 1000)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.CPSettings), entity.CPSettings.Length, 1000));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.CPSettings, entity.CPSettings));
            if (entity.EarthworkBlockImplementationInfo == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.EarthworkBlockImplementationInfo));
            }
            if (entity.EarthworkBlockImplementationInfo.Length > 1000)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.EarthworkBlockImplementationInfo), entity.EarthworkBlockImplementationInfo.Length, 1000));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.EarthworkBlockImplementationInfo, entity.EarthworkBlockImplementationInfo));
            query.InsertBuilders.Add(builder);
            return(session.GetQueryOperator().Insert <TEarthworkBlock>(query));
        }
Exemplo n.º 4
0
        public static bool DbInsert(this TDepthNode entity, DbSession session)
        {
            var           query   = session.GetDbQueryBuilder();
            InsertBuilder builder = new InsertBuilder();

            if (entity.Segregation == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Segregation));
            }
            if (entity.Segregation.Length > 36)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.Segregation), entity.Segregation.Length, 36));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeProperties.Segregation, entity.Segregation));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeProperties.IssueType, entity.IssueType));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeProperties.IssueDateTime, entity.IssueDateTime));
            if (entity.NodeCode == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.NodeCode));
            }
            if (entity.NodeCode.Length > 20)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.NodeCode), entity.NodeCode.Length, 20));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeProperties.NodeCode, entity.NodeCode));
            if (entity.Depth == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Depth));
            }
            if (entity.Depth.Length > 10)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.Depth), entity.Depth.Length, 10));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeProperties.Depth, entity.Depth));
            if (entity.Data == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Data));
            }
            if (entity.Data.Length > 1000)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.Data), entity.Data.Length, 1000));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeProperties.Data, entity.Data));
            if (entity.ElementIds == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.ElementIds));
            }
            if (entity.ElementIds.Length > 2000)
            {
                throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.ElementIds), entity.ElementIds.Length, 2000));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeProperties.ElementIds, entity.ElementIds));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeProperties.Index, entity.Index));
            query.InsertBuilders.Add(builder);
            return(session.GetQueryOperator().Insert <TDepthNode>(query));
        }
Exemplo n.º 5
0
        public static bool DbInsert(this TTeamCreature entity, DbSession session)
        {
            var           query   = IORMProvider.GetDbQueryBuilder(session);
            InsertBuilder builder = new InsertBuilder();

            builder.ComponentInsert.Add(new ComponentValueOfInsert(TTeamCreatureProperties.TeamId, entity.TeamId));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TTeamCreatureProperties.CreatureId, entity.CreatureId));
            query.InsertBuilders.Add(builder);
            return(IORMProvider.GetQueryOperator(session).Insert <TTeamCreature>(session, query));
        }
Exemplo n.º 6
0
        public bool Insert(SupportContract model)
        {
            var bulider = new InsertBuilder("support")
                          .RegisterField("ResourceId", model.ResourceId)
                          .RegisterField("SupportNum", model.SupportNum)
                          .RegisterField("OpposeNum", model.OpposeNum)
                          .RegisterField("ReadNum", model.ReadNum);

            return(AdoProvide.ExecuteNonQuery(WriteConnectionString, bulider) > 0);
        }
Exemplo n.º 7
0
        private void RepackInsertSQL(InsertBuilder insert)
        {
            var provider = insert.Values;

            if (provider != null && provider is SelectBuilder)
            {
                var selectBuilder = provider as SelectBuilder;
                RepackSelectSQL(selectBuilder);
            }
        }
Exemplo n.º 8
0
        public static bool DbInsert(this TAreaEvent entity, DbSession session)
        {
            var           query   = IORMProvider.GetDbQueryBuilder(session);
            InsertBuilder builder = new InsertBuilder();

            builder.ComponentInsert.Add(new ComponentValueOfInsert(TAreaEventProperties.AreaId, entity.AreaId));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TAreaEventProperties.EventId, entity.EventId));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TAreaEventProperties.RoundNum, entity.RoundNum));
            query.InsertBuilders.Add(builder);
            return(IORMProvider.GetQueryOperator(session).Insert <TAreaEvent>(session, query));
        }
Exemplo n.º 9
0
        public bool InsertRecord(SupportRecordContract model)
        {
            var bulider = new InsertBuilder("supportrecord")
                          .RegisterField("UserId", model.UserId)
                          .RegisterField("UserName", model.UserName)
                          .RegisterField("ResourceId", model.ResourceId)
                          .RegisterField("CreateDate", model.CreatDate)
                          .RegisterField("Status", model.Status);

            return(AdoProvide.ExecuteNonQuery(WriteConnectionString, bulider) > 0);
        }
Exemplo n.º 10
0
        public override async Task <long> ExecuteReturnBigIdentityAsync()
        {
            InsertBuilder.IsReturnIdentity = true;
            PreToSql();
            string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault());

            RestoreMapping();
            var result = Convert.ToInt64(await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");

            return(result);
        }
Exemplo n.º 11
0
        public override int ExecuteReturnIdentity()
        {
            InsertBuilder.IsReturnIdentity = true;
            PreToSql();
            string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", GetIdentityKeys().FirstOrDefault());

            RestoreMapping();
            var result = Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()).ObjToInt();

            return(result);
        }
Exemplo n.º 12
0
 protected override void VisitInsert(InsertBuilder item)
 {
     GuardInsertBuilder(item);
     item.Table.Source.Accept(this);
     Columns = item.Columns.ToArray();
     item.Values.Accept(this);
     Columns = null;
     CurrentRequest.Target = EntityBuilder.Build();
     EntityBuilder         = null;
     OutputColumns         = item.Output.ToArray();
     UpgradeToExecuteMultipleIfNecessary();
 }
        public static bool DbInsert(this TCreatureQuality entity, DbSession session)
        {
            var           query   = IORMProvider.GetDbQueryBuilder(session);
            InsertBuilder builder = new InsertBuilder();

            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureQualityProperties.CreatureId, entity.CreatureId));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureQualityProperties.FirstLevelQuality, entity.FirstLevelQuality));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureQualityProperties.SecondLevelQuality, entity.SecondLevelQuality));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureQualityProperties.ThirdLevelQuality, entity.ThirdLevelQuality));
            query.InsertBuilders.Add(builder);
            return(IORMProvider.GetQueryOperator(session).Insert <TCreatureQuality>(session, query));
        }
Exemplo n.º 14
0
        public static bool DbInsert(this TMSAlgorithmSettings entity, DbSession session)
        {
            var           query   = IORMProvider.GetDbQueryBuilder(session);
            InsertBuilder builder = new InsertBuilder();

            builder.ComponentInsert.Add(new ComponentValueOfInsert(TMSAlgorithmSettingsProperties.AlgorithmId, entity.AlgorithmId));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TMSAlgorithmSettingsProperties.TopWeightType, entity.TopWeightType));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TMSAlgorithmSettingsProperties.SubWeightType, entity.SubWeightType));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TMSAlgorithmSettingsProperties.ResultType, entity.ResultType));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TMSAlgorithmSettingsProperties.WeightValue, entity.WeightValue));
            query.InsertBuilders.Add(builder);
            return(IORMProvider.GetQueryOperator(session).Insert <TMSAlgorithmSettings>(session, query));
        }
Exemplo n.º 15
0
        /// <summary>
        /// 返回 是否成功新增
        /// </summary>
        public override bool Insert <T>(DbSession session, InsertBuilder insertBuilder)
        {
            if (insertBuilder == null)
            {
                throw new NotImplementedException("缺少有效的" + nameof(InsertBuilder));
            }
            DbCommand command = session.CreateCommand();

            command.CommandText = insertBuilder.ToQueryString(session, new T().TableName);
            insertBuilder.AddParameter(command, session);
            WriteQueryLog(command, session);
            return(session.ExecuteNonQuery(command) > 0);
        }
        /// <summary>
        /// 添加资源打包布置总表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public long InsertWorkFilePackage(WorkFilePackageContract model)
        {
            var bulider = new InsertBuilder("workfilepackage")
                          .RegisterField("RecordId", model.RecordId)
                          .RegisterField("FilePackageName", model.FilePackageName)
                          .RegisterField("FilePackageType", model.FilePackageType)
                          .RegisterField("UserId", model.UserId)
                          .RegisterField("UserName", model.UserName ?? string.Empty)
                          .RegisterField("CreateDate", model.CreateDate)
                          .RegisterField("Status", model.Status);

            return(AdoProvide.ExecuteScalar <long>(WriteConnectionString, bulider));
        }
Exemplo n.º 17
0
        public void Create_Ignores_Server_Generated_Primary_Keys()
        {
            var schema = new SchemaBuilder()
                         .Define <ServerPrimaryKey>()
                         .Build();
            var entity = new ServerPrimaryKey();
            var query  = InsertBuilder <ServerPrimaryKey> .Create(schema, entity)
                         .BuildQuery() as InsertExpression;

            Assert.AreEqual(0, query.Columns.Length);
            Assert.AreEqual(1, query.RowsExpressions.Length);
            Assert.AreEqual(0, query.RowsExpressions[0].Length);
        }
Exemplo n.º 18
0
        public static bool DbInsert(this TTeam entity, DbSession session)
        {
            var           query   = IORMProvider.GetDbQueryBuilder(session);
            InsertBuilder builder = new InsertBuilder();

            builder.ComponentInsert.Add(new ComponentValueOfInsert(TTeamProperties.TeamId, entity.TeamId));
            if (entity.Name == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Name));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TTeamProperties.Name, entity.Name));
            query.InsertBuilders.Add(builder);
            return(IORMProvider.GetQueryOperator(session).Insert <TTeam>(session, query));
        }
        private void InsertInitialResponses(IEnumerable <IMessageRecipientInfo> recipients, int bulkEmailRId,
                                            string insertTemplate)
        {
            var initialStatusInsertBuilder = new InsertBuilder(UserConnection, insertTemplate, SelectForInsertTemplate);
            var mailingStartTS             = Utilities.ConvertDateTimeToTimestamp(DateTime.UtcNow);

            foreach (var recipient in recipients)
            {
                var recipientId = recipient.Id.ToString().ToUpper();
                initialStatusInsertBuilder.InsertRow(recipientId, bulkEmailRId, recipient.ContactRId,
                                                     recipient.InitialResponseCode, mailingStartTS);
            }
            initialStatusInsertBuilder.ExecuteInsert();
        }
Exemplo n.º 20
0
        /// <summary>
        /// 添加资源打包布置总表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public long InsertPublishRecord(PublishRecordContract model)
        {
            var bulider = new InsertBuilder("publishRecord")
                          .RegisterField("ProductId", model.ProductId)
                          .RegisterField("AppId", model.AppId)
                          .RegisterField("PackageId", model.PackageId)
                          .RegisterField("PackageName", model.PackageName ?? string.Empty)
                          .RegisterField("PackageType", model.PackageType)
                          .RegisterField("UserId", model.UserId)
                          .RegisterField("UserName", model.UserName ?? string.Empty)
                          .RegisterField("CreateDate", model.CreateDate)
                          .RegisterField("Status", model.Status);

            return(AdoProvide.ExecuteScalar <long>(WriteConnectionString, bulider));
        }
Exemplo n.º 21
0
        public override long ExecuteReturnBigIdentity()
        {
            InsertBuilder.IsReturnIdentity = true;
            PreToSql();
            string sql = InsertBuilder.ToSqlString();

            RestoreMapping();
            var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;

            this.Context.Ado.IsDisableMasterSlaveSeparation = true;
            var count  = Ado.ExecuteCommand(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
            var result = (this.GetIdentityKeys().IsNullOrEmpty() || count == 0) ? 0 :Convert.ToInt64(GetSeqValue(GetSeqName()));

            this.Context.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
            return(result);
        }
Exemplo n.º 22
0
        public static bool DbInsert(this TCreatureProperty entity, DbSession session)
        {
            var           query   = IORMProvider.GetDbQueryBuilder(session);
            InsertBuilder builder = new InsertBuilder();

            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreaturePropertyProperties.CreatureId, entity.CreatureId));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreaturePropertyProperties.HitPoint, entity.HitPoint));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreaturePropertyProperties.MagicPoint, entity.MagicPoint));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreaturePropertyProperties.Strength, entity.Strength));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreaturePropertyProperties.Stamina, entity.Stamina));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreaturePropertyProperties.Agility, entity.Agility));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreaturePropertyProperties.Intelligence, entity.Intelligence));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreaturePropertyProperties.Mentality, entity.Mentality));
            query.InsertBuilders.Add(builder);
            return(IORMProvider.GetQueryOperator(session).Insert <TCreatureProperty>(session, query));
        }
Exemplo n.º 23
0
        public static bool DbInsert(this List <TDepthNodeElement> entities, DbSession session)
        {
            var query = session.GetDbQueryBuilder();

            foreach (var entity in entities)
            {
                InsertBuilder builder = new InsertBuilder();
                if (entity.Segregation == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Segregation));
                }
                if (entity.Segregation.Length > 36)
                {
                    throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.Segregation), entity.Segregation.Length, 36));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeElementProperties.Segregation, entity.Segregation));
                if (entity.NodeCode == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.NodeCode));
                }
                if (entity.NodeCode.Length > 20)
                {
                    throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.NodeCode), entity.NodeCode.Length, 20));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeElementProperties.NodeCode, entity.NodeCode));
                if (entity.Depth == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Depth));
                }
                if (entity.Depth.Length > 10)
                {
                    throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.Depth), entity.Depth.Length, 10));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeElementProperties.Depth, entity.Depth));
                if (entity.ElementIds == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.ElementIds));
                }
                if (entity.ElementIds.Length > 2000)
                {
                    throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.ElementIds), entity.ElementIds.Length, 2000));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TDepthNodeElementProperties.ElementIds, entity.ElementIds));
                query.InsertBuilders.Add(builder);
            }
            return(session.GetQueryOperator().InsertAll <TDepthNodeElement>(query));
        }
Exemplo n.º 24
0
        public static bool DbInsert(this List <TCreatureSkill> entities, DbSession session)
        {
            var query = IORMProvider.GetDbQueryBuilder(session);

            foreach (var entity in entities)
            {
                InsertBuilder builder = new InsertBuilder();
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureSkillProperties.CreatureId, entity.CreatureId));
                if (entity.SurvivalSkill == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.SurvivalSkill));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureSkillProperties.SurvivalSkill, entity.SurvivalSkill));
                if (entity.WarriorSkills == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.WarriorSkills));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureSkillProperties.WarriorSkills, entity.WarriorSkills));
                if (entity.ExplorerSkills == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.ExplorerSkills));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureSkillProperties.ExplorerSkills, entity.ExplorerSkills));
                if (entity.FarmingSkills == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.FarmingSkills));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureSkillProperties.FarmingSkills, entity.FarmingSkills));
                if (entity.RasingSkills == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.RasingSkills));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureSkillProperties.RasingSkills, entity.RasingSkills));
                if (entity.BowmanSkills == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.BowmanSkills));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureSkillProperties.BowmanSkills, entity.BowmanSkills));
                if (entity.FishingSkills == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.FishingSkills));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureSkillProperties.FishingSkills, entity.FishingSkills));
                query.InsertBuilders.Add(builder);
            }
            return(IORMProvider.GetQueryOperator(session).InsertAll <TCreatureSkill>(session, query));
        }
Exemplo n.º 25
0
        public static bool DbInsert(this List <TSpider> entities, DbSession session)
        {
            var query = IORMProvider.GetDbQueryBuilder(session);

            foreach (var entity in entities)
            {
                InsertBuilder builder = new InsertBuilder();
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TSpiderProperties.SpiderId, entity.SpiderId));
                if (entity.SpiderName == null)
                {
                    throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.SpiderName));
                }
                builder.ComponentInsert.Add(new ComponentValueOfInsert(TSpiderProperties.SpiderName, entity.SpiderName));
                query.InsertBuilders.Add(builder);
            }
            return(IORMProvider.GetQueryOperator(session).InsertAll <TSpider>(session, query));
        }
Exemplo n.º 26
0
 private void visitInsert(InsertBuilder item)
 {
     writer.Write("INSERT INTO ");
     forSourceContext(SourceReferenceType.Declaration).visitAliasedSource(item.Table);
     if (item.Columns.Any())
     {
         writer.Write(" (");
         forValueContext(ValueReferenceType.Reference).join(", ", item.Columns);
         writer.Write(")");
     }
     writer.Write(" ");
     if (item.Values.IsValueList)
     {
         writer.Write("VALUES");
     }
     item.Values.Accept(forSubCommand().forValueContext(ValueReferenceType.Reference));
 }
Exemplo n.º 27
0
        public void Create_From_View_Returns_Entity_Insert()
        {
            var schema = new SchemaBuilder()
                         .Define <SimpleEntity>()
                         .Build();
            var entity = new { Property = "1234" };
            var query  = InsertBuilder <SimpleEntity> .Create(schema, entity)
                         .BuildQuery() as InsertExpression;

            Assert.IsNotNull(query);
            Assert.AreEqual("SimpleEntity", query.Table.TableName);
            Assert.AreEqual(1, query.Columns.Length);
            Assert.AreEqual("Property", query.Columns[0].ColumnName);
            Assert.AreEqual(1, query.RowsExpressions.Length);
            Assert.AreEqual(1, query.RowsExpressions[0].Length);
            Assert.AreEqual(entity.Property, ((ValueExpression)query.RowsExpressions[0][0]).Value);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 批量更新,sequence Id 不需要处理,domain上加attribute
        /// domian中可空类型string与datetime默认更新为""与当前日期 ,其他可空类型必须传入有效值
        /// </summary>
        /// <param name="domains">domain 列表</param>
        /// <param name="cols">需要插入的列</param>
        public virtual int BatchInsert(List <TDomain> domains, params Expression <Func <TDomain, object> >[] cols)
        {
            if (domains.Count == 0)
            {
                return(0);
            }
            BatchOracleHelper oracleHelper = new BatchOracleHelper(QuerySession);

            var columnRowData = GetData(domains, cols);

            string[] usedProperies = cols.Select(expression => expression.PropertyName()).ToArray();
            Table    table         = GetTable(this.DefaultColumnMapperStrategy);
            InsertBuilder <TDomain> insertBuilder = new InsertBuilder <TDomain>(table, domains[0], QuerySession.DatabaseInfo.SqlDialect, usedProperies);
            string sql = insertBuilder.CreateSql();

            return(oracleHelper.BatchInsertOrUpdate(sql, columnRowData));
        }
Exemplo n.º 29
0
        public static bool DbInsert(this TCreature entity, DbSession session)
        {
            var           query   = IORMProvider.GetDbQueryBuilder(session);
            InsertBuilder builder = new InsertBuilder();

            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureProperties.CreatureId, entity.CreatureId));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureProperties.CreatureType, entity.CreatureType));
            if (entity.Name == null)
            {
                throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Name));
            }
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureProperties.Name, entity.Name));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureProperties.Experience, entity.Experience));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureProperties.Level, entity.Level));
            builder.ComponentInsert.Add(new ComponentValueOfInsert(TCreatureProperties.Profession, entity.Profession));
            query.InsertBuilders.Add(builder);
            return(IORMProvider.GetQueryOperator(session).Insert <TCreature>(session, query));
        }
Exemplo n.º 30
0
        /// <summary>
        /// 添加打包资源
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public long InsertWorkResource(WorkResourceContract model)
        {
            var bulider = new InsertBuilder("workResource")
                          .RegisterField("RecordId", model.RecordId)
                          .RegisterField("PackageId", model.PackageId)
                          .RegisterField("TaskId", model.TaskId)
                          .RegisterField("ModuleId", model.ModuleId)
                          .RegisterField("VersionId", model.VersionId)
                          .RegisterField("RelationPath", model.RelationPath ?? model.VersionId.ToString())
                          .RegisterField("SonModuleId", model.SonModuleId ?? string.Empty)
                          .RegisterField("ResourceName", model.ResourceName ?? string.Empty)
                          .RegisterField("ResourceType", model.ResourceType ?? string.Empty)
                          .RegisterField("RequirementContent", model.RequirementContent ?? string.Empty)
                          .RegisterField("IsFull", model.IsFull);

            model.ContentId = AdoProvide.ExecuteScalar <long>(WriteConnectionString, bulider);
            return(model.ContentId);
        }
Exemplo n.º 31
0
        public void ShouldBeBuildable()
        {
            //Given
            var expected =
                @"INSERT INTO customer
(first_name, last_name, age)
VALUES
(@toadstool_1, @toadstool_2, @toadstool_3)";

            //When
            var actual = new InsertBuilder("customer")
                         .Columns("first_name", "last_name", "age")
                         .Values("Jose", "Cuervo", 100)
                         .Build();

            //Then
            Assert.NotNull(actual);
            Assert.Equal(expected, actual);
        }