我是 esent 的新手,我浏览了一些示例代码,发现可以根据键读取行。从任何特定表中读取所有行的方法是什么。就像我们在 sql 中所做的那样
“从表名中选择 *”
EDB 无法像在 SQL 中那样使用查询。相反,您可以使用 esent API 提供的函数来访问数据库。最终它将如下所示:
CreateInstance
Init
BeginSession
AttachDatabase
OpenDatabase
OpenTable
RetrieveColumns (这是您实际读取数据的地方)
...
当然,有许多功能和特性可以加速您的数据库事务。但是您必须处理下面提到的接口之一:
您可以尝试使用 Microsoft 提供的 API。它有很好的文档记录并且可以在这里免费获得:Extensible Storage Engine
或者您可以使用托管 Esent 接口,您可以轻松地将其与 Visual Studio 一起使用:ESENT 托管互操作
可扩展存储引擎(ESE)中没有查询处理器。这意味着没有可以将文本查询转换为代码的组件。
在术语中,ESE 是一种索引顺序访问方法( ISAM )。
这意味着如果您想查询客户:
SELECT FirstName, LastName FROM Customers
WHERE AccountNumber = 6191128
你必须:
6191128
在伪代码中:
//Use the InvoiceDate index on invoices
db.SetCurrentIndex("IX_Invoices_InvoiceDate");
db.ClearSearchPredicate();
db.AddSearchPredicate(SEEK_GreaterOrEqual, "20170801");
db.AddSearchPredicate(SEEK_LessThen, "20180901");
//read matching primary keys into list
List<Guid> invoiceIDs = new List<Guid>();
IDataReader rdr = db.GetResults();
while (rdr.Read()) do
{
invoiceIDs.Add(rdr.GetGUID("InvoiceGUID"));
}
//Now use the primary clustered key to read the invoice numbers, and customer IDs
db.SetCurrentIndex("PK_Invoices");
for (Guid invoiceID in invoiceIDs) do
{
db.ClearSearchPredicate();
db.AddSearchPrediate(SEEK_Equal, invoiceID);
rdr = db.GetResults();
if rdr.Read() then
{
//todo: store these in another list
customerID = rdr.GetInt32("CustomerID");
invoiceNumber = rdr.GetInt32("InvoiceNumber");
}
}
//Now seek for customers by customerID
db.ClearSearchPredicate()
db.AddSearchPredicate(SEEK_Equal, customerID);
rdr = db.GetResults();
if rdr.Read() then
{
String name = rdr.GetString("Name");
String isActive = rdr.GetString("IsActive");
}