Exemplo n.º 1
0
 public void Setup()
 {
     this.managed = new JET_UNICODEINDEX()
     {
         lcid = 1033,
         dwMapFlags = 0x400,
     };
     this.native = this.managed.GetNativeUnicodeIndex();
 }
Exemplo n.º 2
0
        public void SortDataCaseSensitiveWithJetOpenTemporaryTable()
        {
            if (!EsentVersion.SupportsVistaFeatures)
            {
                return;
            }

            var columns = new[]
            {
                new JET_COLUMNDEF { coltyp = JET_coltyp.Text, cp = JET_CP.Unicode, grbit = ColumndefGrbit.TTKey },
            };
            var columnids = new JET_COLUMNID[columns.Length];

            var idxunicode = new JET_UNICODEINDEX
            {
                dwMapFlags = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None),
                lcid = 1033,
            };

            var opentemporarytable = new JET_OPENTEMPORARYTABLE
            {
                cbKeyMost = SystemParameters.KeyMost,
                ccolumn = columns.Length,
                grbit = TempTableGrbit.Scrollable,
                pidxunicode = idxunicode,
                prgcolumndef = columns,
                prgcolumnid = columnids,
            };
            VistaApi.JetOpenTemporaryTable(this.session, opentemporarytable);

            var data = new[] { "g", "a", "A", "aa", "x", "b", "X" };
            foreach (string s in data)
            {
                using (var update = new Update(this.session, opentemporarytable.tableid, JET_prep.Insert))
                {
                    Api.SetColumn(this.session, opentemporarytable.tableid, columnids[0], s, Encoding.Unicode);
                    update.Save();
                }
            }

            Array.Sort(data);
            CollectionAssert.AreEqual(
                data, this.RetrieveAllRecordsAsString(opentemporarytable.tableid, columnids[0]).ToArray());
            Api.JetCloseTable(this.session, opentemporarytable.tableid);
        }
Exemplo n.º 3
0
        public void SortLongValueDataWithJetOpenTempTable3()
        {
            JET_TABLEID tableid;
            var columns = new[]
            {
                new JET_COLUMNDEF { coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = ColumndefGrbit.TTKey },
            };
            var columnids = new JET_COLUMNID[columns.Length];

            var idxunicode = new JET_UNICODEINDEX
            {
                dwMapFlags = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None),
                lcid = 1033,
            };
            Api.JetOpenTempTable3(this.session, columns, columns.Length, idxunicode, TempTableGrbit.Scrollable, out tableid, columnids);

            var data = new[]
            {
                Any.StringOfLength(1999),
                Any.StringOfLength(2000),
                Any.StringOfLength(1999),
                Any.StringOfLength(2000),
                Any.StringOfLength(2001),
                Any.StringOfLength(2000),
                Any.StringOfLength(1999),
            };

            using (var transaction = new Transaction(this.session))
            {
                foreach (string s in data)
                {
                    using (var update = new Update(this.session, tableid, JET_prep.Insert))
                    {
                        Api.SetColumn(this.session, tableid, columnids[0], s, Encoding.Unicode);
                        update.Save();
                    }
                }

                transaction.Commit(CommitTransactionGrbit.None);
            }

            Array.Sort(data);
            CollectionAssert.AreEqual(data, this.RetrieveAllRecordsAsString(tableid, columnids[0]).ToArray());
            Api.JetCloseTable(this.session, tableid);
        }
Exemplo n.º 4
0
        public void SortDataCaseSensitiveWithJetOpenTempTable3()
        {
            JET_TABLEID tableid;
            var columns = new[]
            {
                new JET_COLUMNDEF { coltyp = JET_coltyp.Text, cp = JET_CP.Unicode, grbit = ColumndefGrbit.TTKey },
            };
            var columnids = new JET_COLUMNID[columns.Length];

            var idxunicode = new JET_UNICODEINDEX
            {
                dwMapFlags = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None),
                lcid = 1033,
            };
            Api.JetOpenTempTable3(this.session, columns, columns.Length, idxunicode, TempTableGrbit.Scrollable, out tableid, columnids);

            var data = new[] { "g", "a", "A", "aa", "x", "b", "X" };
            foreach (string s in data)
            {
                using (var update = new Update(this.session, tableid, JET_prep.Insert))
                {
                    Api.SetColumn(this.session, tableid, columnids[0], s, Encoding.Unicode);
                    update.Save();
                }
            }

            Array.Sort(data);
            CollectionAssert.AreEqual(data, this.RetrieveAllRecordsAsString(tableid, columnids[0]).ToArray());
            Api.JetCloseTable(this.session, tableid);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a temporary table with a single index. A temporary table
 /// stores and retrieves records just like an ordinary table created
 /// using JetCreateTableColumnIndex. However, temporary tables are
 /// much faster than ordinary tables due to their volatile nature.
 /// They can also be used to very quickly sort and perform duplicate
 /// removal on record sets when accessed in a purely sequential manner.
 /// Also see
 /// <seealso cref="Api.JetOpenTempTable"/>,
 /// <seealso cref="Api.JetOpenTempTable2"/>,
 /// <seealso cref="VistaApi.JetOpenTemporaryTable"/>.
 /// </summary>
 /// <param name="sesid">The session to use.</param>
 /// <param name="columns">
 /// Column definitions for the columns created in the temporary table.
 /// </param>
 /// <param name="numColumns">Number of column definitions.</param>
 /// <param name="unicodeindex">
 /// The Locale ID and normalization flags that will be used to compare
 /// any Unicode key column data in the temporary table. When this 
 /// is not present then the default options are used. 
 /// </param>
 /// <param name="grbit">Table creation options.</param>
 /// <param name="tableid">
 /// Returns the tableid of the temporary table. Closing this tableid
 /// with <see cref="JetCloseTable"/> frees the resources associated
 /// with the temporary table.
 /// </param>
 /// <param name="columnids">
 /// The output buffer that receives the array of column IDs generated
 /// during the creation of the temporary table. The column IDs in this
 /// array will exactly correspond to the input array of column definitions.
 /// As a result, the size of this buffer must correspond to the size of
 /// the input array.
 /// </param>
 public static void JetOpenTempTable3(
     JET_SESID sesid,
     JET_COLUMNDEF[] columns,
     int numColumns,
     JET_UNICODEINDEX unicodeindex,
     TempTableGrbit grbit,
     out JET_TABLEID tableid,
     JET_COLUMNID[] columnids)
 {
     Api.Check(Impl.JetOpenTempTable3(sesid, columns, numColumns, unicodeindex, grbit, out tableid, columnids));            
 }
Exemplo n.º 6
0
        public void GetIndexInformationOneIndexWithCompareOptions()
        {
            const string Indexname = "myindex";
            const string Indexdef = "-unicode\0\0";

            var pidxUnicode = new JET_UNICODEINDEX
            {
                lcid = CultureInfo.CurrentCulture.LCID,
                dwMapFlags = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase),
            };

            var indexcreate = new JET_INDEXCREATE
            {
                szIndexName = Indexname,
                szKey = Indexdef,
                cbKey = Indexdef.Length,
                grbit = CreateIndexGrbit.IndexDisallowNull,
                pidxUnicode = pidxUnicode,
            };

            Api.JetBeginTransaction(this.sesid);
            Api.JetCreateIndex2(this.sesid, this.tableid, new[] { indexcreate }, 1);
            IEnumerable<IndexInfo> indexes = Api.GetTableIndexes(this.sesid, this.tableid);

            // There should be only one index
            IndexInfo info = indexes.Single();
            Assert.AreEqual(Indexname, info.Name);
            Assert.AreEqual(CreateIndexGrbit.IndexDisallowNull, info.Grbit);

            Assert.AreEqual(1, info.IndexSegments.Count);
            Assert.AreEqual("unicode", info.IndexSegments[0].ColumnName, true);
            Assert.IsFalse(info.IndexSegments[0].IsAscending);
            Assert.AreEqual(JET_coltyp.LongText, info.IndexSegments[0].Coltyp);
            Assert.IsFalse(info.IndexSegments[0].IsASCII);
            Assert.AreEqual(CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase, info.CompareOptions);

            Api.JetRollback(this.sesid, RollbackTransactionGrbit.None);
        }
Exemplo n.º 7
0
 public void JetUnicodeIndexToString()
 {
     var unicodeindex = new JET_UNICODEINDEX { lcid = 1033, dwMapFlags = 0x12f };
     Assert.AreEqual("JET_UNICODEINDEX(1033:0x12F)", unicodeindex.ToString());
 }