welsonjs/WelsonJS.Toolkit/WelsonJS.Esent
2025-06-26 10:50:34 +09:00
..
assets Update README.md (WelsonJS.Esent) 2025-06-26 10:49:40 +09:00
Column.cs Update EsentDatabase specs 2025-06-26 10:22:07 +09:00
EsentDatabase.cs Fix the null check for schema should occur before accessing schema.PrimaryKey 2025-06-26 10:26:59 +09:00
ICompatibleLogger.cs Update EsentDatabase specs 2025-06-26 10:22:07 +09:00
LICENSE Add the package ManagedEsent, and WelsonJS.Esent 2025-06-24 17:55:34 +09:00
README.md Update README.md (WelsonJS.Esent) 2025-06-26 10:49:40 +09:00
Schema.cs Update EsentDatabase specs 2025-06-26 10:22:07 +09:00
TraceLogger.cs Update EsentDatabase specs 2025-06-26 10:22:07 +09:00
WelsonJS.Esent.csproj Update EsentDatabase specs 2025-06-26 10:22:07 +09:00

WelsonJS.Esent

WelsonJS.Esent is a library that enables the use of the ESENT database (also known as the Extensible Storage Engine or JET Blue).

Although it was developed to support the WelsonJS framework, it can be used in any .NET-based project.

For more details, refer to the WelsonJS Documentation.

Example code

using WelsonJS.Esent;

// connect the database to manage instances
Schema schema = new Schema("Instances", new List<Column>
{
    new Column("InstanceId", typeof(string), 255),
    new Column("FirstDeployTime", typeof(DateTime), 1)
});
schema.SetPrimaryKey("InstanceId");
_db = new EsentDatabase(schema, Path.GetTempPath());

// Insert row
try
{
    _db.Insert(new Dictionary<string, object>
    {
        ["InstanceId"] = instanceId,
        ["FirstDeployTime"] = now
    }, out _);
}
catch (Exception ex)
{
    // Handle exception
}

// find all
var instances = _db.FindAll();
foreach (var instance in instances)
{
    try
    {
        string instanceId = instance["InstanceId"].ToString();
        string firstDeployTime = instance.ContainsKey("FirstDeployTime")
            ? ((DateTime)instance["FirstDeployTime"]).ToString("yyyy-MM-dd HH:mm:ss")
            : "Unknown";

        Console.WriteLine($"{firstDeployTime}, {instanceId}");
    }
    catch (Exception ex)
    {
        // Handle exception
    }
}

Source code available: https://github.com/gnh1201/welsonjs