当前位置: 首页>>代码示例>>C#>>正文


C# Connection.OpenConfig方法代码示例

本文整理汇总了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");
            }
        }
开发者ID:midgardproject,项目名称:midgard-mono,代码行数:30,代码来源:storage.cs

示例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!");
        }
开发者ID:midgardproject,项目名称:midgard-mono,代码行数:17,代码来源:connection.cs

示例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);
        }
开发者ID:midgardproject,项目名称:midgard-mono,代码行数:43,代码来源:objects.cs

示例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);
        }
开发者ID:midgardproject,项目名称:midgard-mono,代码行数:36,代码来源:QuerySelect.cs


注:本文中的Connection.OpenConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。