diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/MetadataStore.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/MetadataStore.cs index c6547a7..cb1180a 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/MetadataStore.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/MetadataStore.cs @@ -105,22 +105,23 @@ namespace WelsonJS.Launcher Api.JetAddColumn(_session, tableid, col.Name, coldef, null, 0, out _); } - string indexKey = $"+{_primaryKey.Name}\0"; - int keyLength = Encoding.ASCII.GetByteCount(indexKey + "\0"); // double null-terminated - string fullKeyDescription = indexKey + "\0"; + string indexName = "primary"; + string key = $"+{_primaryKey.Name}\0"; + string keyDescription = key + "\0"; // double null-terminated + int keyDescriptionLength = Encoding.ASCII.GetByteCount(keyDescription); // in characters Api.JetCreateIndex( _session, tableid, - "primary", + indexName, CreateIndexGrbit.IndexPrimary | CreateIndexGrbit.IndexUnique, - fullKeyDescription, - keyLength, + keyDescription, + keyDescriptionLength, 100 ); - Api.JetCommitTransaction(_session, CommitTransactionGrbit.None); Api.JetCloseTable(_session, tableid); + Api.JetCommitTransaction(_session, CommitTransactionGrbit.None); } private void CacheColumns() diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Storage/Column.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/Storage/Column.cs index f17060d..430658c 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/Storage/Column.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/Storage/Column.cs @@ -17,6 +17,16 @@ namespace WelsonJS.Launcher.Storage public JET_CP CodePage { get; set; } public bool IsPrimaryKey { get; set; } = false; + public override string ToString() + { + return Name; + } + + public static explicit operator string(Column c) + { + return c.ToString(); + } + public Column(string name, JET_coltyp type, int maxSize = 0, JET_CP codePage = JET_CP.None) { Name = name;