internal static void CreateTable(JET_SESID sesid, JET_DBID dbid)
{
JET_TABLEID tableid;
Api.JetCreateTable(sesid, dbid, GeometryTableName, 8, 80, out tableid);
using (var transaction = new Microsoft.Isam.Esent.Interop.Transaction(sesid))
{
JET_COLUMNID columnid;
var columndef = new JET_COLUMNDEF
{
coltyp = JET_coltyp.Long,
grbit = ColumndefGrbit.ColumnAutoincrement
};
Api.JetAddColumn(sesid, tableid, colNameGeometryLabel, columndef, null, 0, out columnid);
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
Api.JetAddColumn(sesid, tableid, colNameProductLabel, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.UnsignedByte;
Api.JetAddColumn(sesid, tableid, colNameGeomType, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.Short;
Api.JetAddColumn(sesid, tableid, colNameProductIfcTypeId, columndef, null, 0, out columnid);
Api.JetAddColumn(sesid, tableid, colNameSubPart, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.Binary;
columndef.grbit = ColumndefGrbit.ColumnMaybeNull;
Api.JetAddColumn(sesid, tableid, colNameTransformMatrix, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.LongBinary;
//if (EsentVersion.SupportsWindows7Features)
// columndef.grbit |= Windows7Grbits.ColumnCompressed;
Api.JetAddColumn(sesid, tableid, colNameShapeData, columndef, null, 0, out columnid);
columndef.coltyp = JET_coltyp.Long;
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
Api.JetAddColumn(sesid, tableid, colNameGeometryHash, columndef, null, 0, out columnid);
columndef.grbit = ColumndefGrbit.ColumnNotNULL;
Api.JetAddColumn(sesid, tableid, colNameStyleLabel, columndef, null, 0, out columnid);
// The primary index is the type and the entity label.
string indexDef = string.Format("+{0}\0\0", colNameGeometryLabel);
Api.JetCreateIndex(sesid, tableid, geometryTablePrimaryIndex, CreateIndexGrbit.IndexPrimary, indexDef, indexDef.Length, 100);
//create index by geometry hashes
indexDef = string.Format("+{0}\0\0", colNameGeometryHash);
Api.JetCreateIndex(sesid, tableid, geometryTableHashIndex, CreateIndexGrbit.IndexDisallowNull, indexDef, indexDef.Length, 100);
//Create index by product
indexDef = string.Format("+{0}\0{1}\0{2}\0{3}\0{4}\0\0", colNameGeomType, colNameProductIfcTypeId, colNameProductLabel, colNameSubPart, colNameStyleLabel);
Api.JetCreateIndex(sesid, tableid, geometryTableGeomTypeIndex, CreateIndexGrbit.IndexUnique, indexDef, indexDef.Length, 100);
//create index by style
indexDef = string.Format("+{0}\0{1}\0{2}\0{3}\0{4}\0\0", colNameGeomType, colNameStyleLabel, colNameProductIfcTypeId, colNameProductLabel, colNameGeometryLabel);
Api.JetCreateIndex(sesid, tableid, geometryTableStyleIndex, CreateIndexGrbit.None, indexDef, indexDef.Length, 100);
Api.JetCloseTable(sesid, tableid);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
}