本文整理汇总了C#中Connection.OpenConfig方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.OpenConfig方法的具体用法?C# Connection.OpenConfig怎么用?C# Connection.OpenConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.OpenConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
Lib.Init ();
// Create midgard config connection
Config cfg = new Config ();
cfg.DatabaseType = "SQLite";
cfg.DatabaseName = "midgard_mono_sample";
Connection mgd = new Connection ();
if (!mgd.OpenConfig (cfg)) {
Console.WriteLine ("Connection failed!");
return;
}
/* Create base storage if it doesn't exist */
if (Midgard.Storage.CreateBaseStorage(mgd))
Console.WriteLine ("Base Midgard storage created");
/* Create midgard_person storage if it doesn't exist */
if (Midgard.Storage.Exists (mgd, "midgard_person")) {
Console.WriteLine ("Storage for midgard_person class exists");
}
else {
if (Midgard.Storage.Create (mgd, "midgard_person"))
Console.WriteLine ("Created new storage for midgard_person class");
else
Console.WriteLine ("Failed to create storage for midgard_person class");
}
}
示例2: Main
public static void Main(string[] args)
{
Midgard.Lib.Init ();
// Create midgard config connection
Config cfg = new Config ();
cfg.DatabaseType = "SQLite";
cfg.DatabaseName = "midgard";
Connection conn = new Connection ();
if (!conn.OpenConfig (cfg)) {
Console.WriteLine ("Connection failed!");
return;
}
Console.WriteLine ("Connection established!");
}
示例3: Main
public static void Main(string[] args)
{
Midgard.Lib.Init ();
// Create midgard config connection
Config cfg = new Config ();
cfg.DatabaseType = "SQLite";
cfg.DatabaseName = "midgard_mono_sample";
Connection mgd = new Connection ();
if (!mgd.OpenConfig (cfg)) {
Console.WriteLine ("Connection failed!");
return;
}
GLib.Value val = new GLib.Value("");
Midgard.Object john = new Midgard.Object (mgd, "midgard_person", val);
GLib.Value name = new GLib.Value ("John");
john.SetSchemaProperty ("username", name);
if (!john.Create()) {
Console.WriteLine ("Couldn't create person object. %s", mgd.ErrorString);
}
else {
GLib.Value gval = john.GetSchemaProperty ("guid");
Console.Write ("Created new person object." + (string)gval.Val.ToString() + "\n");
}
val = new GLib.Value("");
Midgard.Object alice = new Midgard.Object (mgd, "midgard_person", val);
name = new GLib.Value ("Alice");
alice.SetSchemaProperty ("username", name);
if (!alice.Create()) {
Console.WriteLine ("Couldn't create person object. %s", mgd.ErrorString);
}
else {
GLib.Value gval = alice.GetSchemaProperty ("guid");
Console.Write ("Created new person object." + (string)gval.Val + "\n");
}
Console.WriteLine (john);
}
示例4: Main
public static void Main(string[] args)
{
Midgard.Lib.Init ();
// Create midgard config connection
Config cfg = new Config ();
cfg.DatabaseType = "SQLite";
cfg.DatabaseName = "midgard_mono_sample";
Connection mgd = new Connection ();
if (!mgd.OpenConfig (cfg)) {
Console.WriteLine ("Connection failed!");
return;
}
Midgard.QueryStorage storage = new Midgard.QueryStorage ("midgard_person");
Midgard.QuerySelect select = new Midgard.QuerySelect (mgd, storage);
Midgard.QueryProperty prop = new Midgard.QueryProperty ("name", null);
GLib.Value value = new GLib.Value ("John");
Midgard.QueryValue val = new Midgard.QueryValue (value);
Midgard.QueryConstraint cnstr = new Midgard.QueryConstraint (prop, "=", val, storage);
Midgard.QueryProperty prop2 = new Midgard.QueryProperty ("name", null);
value = new GLib.Value ("Alice");
Midgard.QueryValue val2 = new Midgard.QueryValue (value);
Midgard.QueryConstraint cnstr2 = new Midgard.QueryConstraint (prop2, "=", val, null);
//Midgard.QueryGroupConstraint group_constraint = new Midgard.QueryGroupConstraint ("OR", cnstr, cnstr2);
//select.SetConstraint (cnstr);
select.Execute();
uint nobjects = 0;
Midgard.DBObject[] objects = select.ListObjects(out nobjects);
}