public override void DeleteByIds(IEnumerable <IStructureId> ids, IStructureSchema structureSchema)
        {
            Ensure.That(structureSchema, "structureSchema").IsNotNull();

            var sql = SqlStatements.GetSql("DeleteByIds").Inject(structureSchema.GetStructureTableName());

            using (var cmd = CreateCommand(sql))
            {
                foreach (var idBatch in ids.Batch(MaxBatchedIdsSize))
                {
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add(SqlServerIdsTableParam.CreateIdsTableParam(structureSchema.IdAccessor.IdType, idBatch));
                    cmd.ExecuteNonQuery();
                }
            }
        }
        public override IEnumerable <string> GetJsonByIds(IEnumerable <IStructureId> ids, IStructureSchema structureSchema)
        {
            Ensure.That(structureSchema, "structureSchema").IsNotNull();

            var sql = SqlStatements.GetSql("GetJsonByIds").Inject(structureSchema.GetStructureTableName());

            using (var cmd = CreateCommand(sql))
            {
                foreach (var idBatch in ids.Batch(MaxBatchedIdsSize))
                {
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add(SqlServerIdsTableParam.CreateIdsTableParam(structureSchema.IdAccessor.IdType, idBatch));

                    foreach (var data in YieldJson(structureSchema, cmd))
                    {
                        yield return(data);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public override IEnumerable <string> GetJsonByIds(IEnumerable <IStructureId> ids, IStructureSchema structureSchema)
        {
            Ensure.That(structureSchema, "structureSchema").IsNotNull();

            var sql = SqlStatements.GetSql("GetJsonByIds").Inject(structureSchema.GetStructureTableName());

            using (var cmd = CreateCommand(sql))
            {
                foreach (var idBatch in ids.Batch(MaxBatchedIdsSize))
                {
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add(SqlServerIdsTableParam.CreateIdsTableParam(structureSchema.IdAccessor.IdType, idBatch));

                    using (var reader = cmd.ExecuteReader(CommandBehavior.SingleResult | CommandBehavior.SequentialAccess))
                    {
                        while (reader.Read())
                        {
                            yield return(reader.GetString(0));
                        }
                        reader.Close();
                    }
                }
            }
        }