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


C# IDbConnection.GetSqlType方法代码示例

本文整理汇总了C#中IDbConnection.GetSqlType方法的典型用法代码示例。如果您正苦于以下问题:C# IDbConnection.GetSqlType方法的具体用法?C# IDbConnection.GetSqlType怎么用?C# IDbConnection.GetSqlType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDbConnection的用法示例。


在下文中一共展示了IDbConnection.GetSqlType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HomeManager

		public HomeManager(IDbConnection db)
		{
			this.db = db;

			var sqlCreator = new SqlTableCreator(db,
				db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
			sqlCreator.EnsureTableStructure(new SqlTable("Homes",
				new SqlColumn("ID", MySqlDbType.Int32) {AutoIncrement = true, Primary = true},
				new SqlColumn("UserID", MySqlDbType.Int32),
				new SqlColumn("Name", MySqlDbType.Text),
				new SqlColumn("X", MySqlDbType.Double),
				new SqlColumn("Y", MySqlDbType.Double),
				new SqlColumn("WorldID", MySqlDbType.Int32)));

			using (QueryResult result = db.QueryReader("SELECT * FROM Homes WHERE WorldID = @0", Main.worldID))
			{
				while (result.Read())
				{
					homes.Add(new Home(
						result.Get<int>("UserID"),
						result.Get<string>("Name"),
						result.Get<float>("X"),
						result.Get<float>("Y")));
				}
			}
		}
开发者ID:WhiteXZ,项目名称:EssentialsPlus,代码行数:26,代码来源:HomeManager.cs

示例2: GroupManager

        public GroupManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("GroupList",
                                     new SqlColumn("GroupName", MySqlDbType.VarChar, 32) {Primary = true},
                                     new SqlColumn("Parent", MySqlDbType.VarChar, 32),
                                     new SqlColumn("Commands", MySqlDbType.Text),
                                     new SqlColumn("ChatColor", MySqlDbType.Text),
                                     new SqlColumn("Prefix", MySqlDbType.Text),
                                     new SqlColumn("Suffix", MySqlDbType.Text)
                );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                              	? (IQueryBuilder) new SqliteQueryCreator()
                                              	: new MysqlQueryCreator());
            creator.EnsureExists(table);

            //Add default groups
            AddGroup("guest", "canbuild,canregister,canlogin,canpartychat,cantalkinthird");
            AddGroup("default", "guest", "warp,canchangepassword");
            AddGroup("newadmin", "default", "kick,editspawn,reservedslot");
            AddGroup("admin", "newadmin",
                     "ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere");
            AddGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,usebanneditem,manageusers");
            AddGroup("vip", "default", "reservedslot");
        }
开发者ID:kmcfate,项目名称:TShock,代码行数:27,代码来源:GroupManager.cs

示例3: GroupManager

        public GroupManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("GroupList",
                new SqlColumn("GroupName", MySqlDbType.VarChar, 32) { Primary = true },
                new SqlColumn("Parent", MySqlDbType.VarChar, 32),
                new SqlColumn("Commands", MySqlDbType.Text),
                new SqlColumn("ChatColor", MySqlDbType.Text)
            );
            var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);

            //Add default groups
            AddGroup("default", "canwater,canlava,warp,canbuild");
            AddGroup("newadmin", "default", "kick,editspawn,reservedslot");
            AddGroup("admin", "newadmin", "ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere");
            AddGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,ignorecheatdetection,ignoregriefdetection,usebanneditem,manageusers");
            AddGroup("vip", "default", "canwater,canlava,warp,canbuild,reservedslot");

            String file = Path.Combine(TShock.SavePath, "groups.txt");
            if (File.Exists(file))
            {
                using (StreamReader sr = new StreamReader(file))
                {
                    String line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (!line.Equals("") && !line.Substring(0, 1).Equals("#"))
                        {
                            String[] info = line.Split(' ');
                            String comms = "";
                            int size = info.Length;
                            for (int i = 1; i < size; i++)
                            {
                                if (!comms.Equals(""))
                                    comms = comms + ",";
                                comms = comms + info[i].Trim();
                            }

                            string query = "";
                            if (TShock.Config.StorageType.ToLower() == "sqlite")
                                query = "INSERT OR IGNORE INTO GroupList (GroupName, Commands) VALUES (@0, @1);";
                            else if (TShock.Config.StorageType.ToLower() == "mysql")
                                query = "INSERT IGNORE INTO GroupList SET [email protected], [email protected];";

                            db.Query(query, info[0].Trim(), comms);

                        }
                    }
                }
                String path = Path.Combine(TShock.SavePath, "old_configs");
                String file2 = Path.Combine(path, "groups.txt");
                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);
                if (File.Exists(file2))
                    File.Delete(file2);
                File.Move(file, file2);
            }
        }
开发者ID:char213,项目名称:TShock,代码行数:60,代码来源:GroupManager.cs

示例4: CharacterManager

        public CharacterManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("tsCharacter",
                                     new SqlColumn("Account", MySqlDbType.Int32) {Primary = true},
                                     new SqlColumn("Health", MySqlDbType.Int32),
                                     new SqlColumn("MaxHealth", MySqlDbType.Int32),
                                     new SqlColumn("Mana", MySqlDbType.Int32),
                                     new SqlColumn("MaxMana", MySqlDbType.Int32),
                                     new SqlColumn("Inventory", MySqlDbType.Text),
                                     new SqlColumn("extraSlot", MySqlDbType.Int32),
                                     new SqlColumn("spawnX", MySqlDbType.Int32),
                                     new SqlColumn("spawnY", MySqlDbType.Int32),
                                     new SqlColumn("skinVariant", MySqlDbType.Int32),
                                     new SqlColumn("hair", MySqlDbType.Int32),
                                     new SqlColumn("hairDye", MySqlDbType.Int32),
                                     new SqlColumn("hairColor", MySqlDbType.Int32),
                                     new SqlColumn("pantsColor", MySqlDbType.Int32),
                                     new SqlColumn("shirtColor", MySqlDbType.Int32),
                                     new SqlColumn("underShirtColor", MySqlDbType.Int32),
                                     new SqlColumn("shoeColor", MySqlDbType.Int32),
                                     new SqlColumn("hideVisuals", MySqlDbType.Int32),
                                     new SqlColumn("skinColor", MySqlDbType.Int32),
                                     new SqlColumn("eyeColor", MySqlDbType.Int32),
                                     new SqlColumn("questsCompleted", MySqlDbType.Int32)
                );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                              	? (IQueryBuilder) new SqliteQueryCreator()
                                              	: new MysqlQueryCreator());
            creator.EnsureTableStructure(table);
        }
开发者ID:sylar605,项目名称:TshockCN,代码行数:33,代码来源:CharacterManager.cs

示例5: DBConnect

        internal static void DBConnect()
        {
            switch (TShock.Config.StorageType.ToLower())
            {
                case "mysql":
                    string[] dbHost = TShock.Config.MySqlHost.Split(':');
                    db = new MySqlConnection()
                    {
                        ConnectionString = string.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
                            dbHost[0],
                            dbHost.Length == 1 ? "3306" : dbHost[1],
                            TShock.Config.MySqlDbName,
                            TShock.Config.MySqlUsername,
                            TShock.Config.MySqlPassword)

                    };
                    break;

                case "sqlite":
                    string sql = Path.Combine(TShock.SavePath, "tshock.sqlite");
                    db = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
                    break;

            }

            SqlTableCreator sqlcreator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());

            sqlcreator.EnsureTableStructure(new SqlTable("NoTpRegions",
                new SqlColumn("Name", MySqlDbType.Text)));
        }
开发者ID:ProfessorXZ,项目名称:NoTpRegions,代码行数:30,代码来源:Database.cs

示例6: BanManager

        /// <summary>
        /// Initializes a new instance of the <see cref="TShockAPI.DB.BanManager"/> class.
        /// </summary>
        /// <param name="db">A valid connection to the TShock database</param>
		public BanManager(IDbConnection db)
		{
			database = db;

			var table = new SqlTable("Bans",
			                         new SqlColumn("IP", MySqlDbType.String, 16) {Primary = true},
			                         new SqlColumn("Name", MySqlDbType.Text),
									 new SqlColumn("UUID", MySqlDbType.Text),
			                         new SqlColumn("Reason", MySqlDbType.Text),
                                     new SqlColumn("BanningUser", MySqlDbType.Text),
                                     new SqlColumn("Date", MySqlDbType.Text),
                                     new SqlColumn("Expiration", MySqlDbType.Text)
				);
			var creator = new SqlTableCreator(db,
			                                  db.GetSqlType() == SqlType.Sqlite
			                                  	? (IQueryBuilder) new SqliteQueryCreator()
			                                  	: new MysqlQueryCreator());
			try
			{
				creator.EnsureTableStructure(table);
			}
			catch (DllNotFoundException)
			{
				System.Console.WriteLine("Possible problem with your database - is Sqlite3.dll present?");
				throw new Exception("Could not find a database library (probably Sqlite3.dll)");
			}
		}
开发者ID:sliekasirdis79,项目名称:TShock,代码行数:31,代码来源:BanManager.cs

示例7: SqlLog

		/// <summary>
		/// Sets the database connection and the initial log level.
		/// </summary>
		/// <param name="db">Database connection</param>
		/// <param name="textlogFilepath">File path to a backup text log in case the SQL log fails</param>
		/// <param name="clearTextLog"></param>
		public SqlLog(IDbConnection db, string textlogFilepath, bool clearTextLog)
		{
			FileName = string.Format("{0}://database", db.GetSqlType());
			_database = db;
			_backupLog = new TextLog(textlogFilepath, clearTextLog);

			var table = new SqlTable("Logs",
				new SqlColumn("ID", MySqlDbType.Int32) {AutoIncrement = true, Primary = true},
				new SqlColumn("TimeStamp", MySqlDbType.Text),
				new SqlColumn("LogLevel", MySqlDbType.Int32),
				new SqlColumn("Caller", MySqlDbType.Text),
				new SqlColumn("Message", MySqlDbType.Text)
				);

			var creator = new SqlTableCreator(db,
				db.GetSqlType() == SqlType.Sqlite
					? (IQueryBuilder) new SqliteQueryCreator()
					: new MysqlQueryCreator());
			creator.EnsureTableStructure(table);
		}
开发者ID:sliekasirdis79,项目名称:TShock,代码行数:26,代码来源:SqlLog.cs

示例8: Initialize

        public static void Initialize()
        {
            if (!Directory.Exists(SavePath))
                Directory.CreateDirectory(SavePath);

            switch (TShock.Config.StorageType.ToLower())
            {
                case "mysql":
                    string[] host = TShock.Config.MySqlHost.Split(':');
                    Database = new MySqlConnection()
                    {
                        ConnectionString = string.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
                                host[0],
                                host.Length == 1 ? "3306" : host[1],
                                TShock.Config.MySqlDbName,
                                TShock.Config.MySqlUsername,
                                TShock.Config.MySqlPassword)
                    };
                    break;
                case "sqlite":
                    string sql = Path.Combine(SavePath, "Clans.sqlite");
                    Database = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
                    break;
            }
            SqlTableCreator SQLcreator = new SqlTableCreator(Database, Database.GetSqlType() == SqlType.Sqlite
            ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());

            SqlTable[] tables = new SqlTable[]
            {
                 new SqlTable("Clans",
                     new SqlColumn("Name", MySqlDbType.VarChar) { Primary=true, Unique=true },
                     new SqlColumn("Owner", MySqlDbType.VarChar),
                     new SqlColumn("InviteMode", MySqlDbType.Int32),
                     new SqlColumn("TileX", MySqlDbType.Int32),
                     new SqlColumn("TileY", MySqlDbType.Int32),
                     new SqlColumn("ChatColor", MySqlDbType.VarChar),
                     new SqlColumn("Bans", MySqlDbType.VarChar)
                     ),
                 new SqlTable("ClanMembers",
                     new SqlColumn("Username",MySqlDbType.VarChar) { Primary=true, Unique=true },
                     new SqlColumn("ClanName", MySqlDbType.VarChar)
                     ),
                 new SqlTable("ClanWarps",
                     new SqlColumn("WarpName",MySqlDbType.VarChar) { Primary=true, Unique=true }                  
                     )
            };

            for (int i = 0; i < tables.Length; i++)
                SQLcreator.EnsureTableStructure(tables[i]);

            Config = Config.Read();
            LoadClans();
        }
开发者ID:MichaelMan57,项目名称:Clans,代码行数:53,代码来源:ClanManager.cs

示例9: ArmorShopManager

        public ArmorShopManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("Armor",
                new SqlColumn("ID", MySqlDbType.Int32) { Primary = true, AutoIncrement = true },
                new SqlColumn("Name", MySqlDbType.VarChar, 32),
                new SqlColumn("InGameName", MySqlDbType.VarChar, 128),
                new SqlColumn("Contains", MySqlDbType.VarChar, 128),
                new SqlColumn("Price", MySqlDbType.Int32));
            var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
开发者ID:RogerPaladin,项目名称:TShock,代码行数:13,代码来源:ArmorShopManager.cs

示例10: ChatManager

        public ChatManager(IDbConnection db)
        {
            database = db;

                var table = new SqlTable("Chat",
                    new SqlColumn("ID", MySqlDbType.Int32) { Primary = true, AutoIncrement = true },
                    new SqlColumn("Username", MySqlDbType.VarChar, 32),
                    new SqlColumn("ToUsername", MySqlDbType.VarChar, 32),
                    new SqlColumn("Message", MySqlDbType.VarChar, 32)
                    );
                var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
                creator.EnsureExists(table);
        }
开发者ID:RogerPaladin,项目名称:TShock,代码行数:13,代码来源:ChatManager.cs

示例11: InventoryManager

        public InventoryManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("Inventory",
                new SqlColumn("Account", MySqlDbType.Int32) { Primary = true },
                new SqlColumn("MaxHealth", MySqlDbType.Int32),
                new SqlColumn("MaxMana", MySqlDbType.Int32),
                new SqlColumn("Inventory", MySqlDbType.Text)
            );
            var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
开发者ID:DaGamesta,项目名称:TShock,代码行数:13,代码来源:InventoryManager.cs

示例12: InventoryManager

        public InventoryManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("Inventory",
                new SqlColumn("Username", MySqlDbType.VarChar, 32) { Unique = true, Primary = true},
                new SqlColumn("Slot0", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot1", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot2", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot3", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot4", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot5", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot6", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot7", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot8", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot9", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot10", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot11", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot12", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot13", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot14", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot15", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot16", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot17", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot18", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot19", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot20", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot21", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot22", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot23", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot24", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot25", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot26", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot27", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot28", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot29", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot30", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot31", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot32", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot33", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot34", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot35", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot36", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot37", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot38", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot39", MySqlDbType.VarChar, 32)
                );
            var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
开发者ID:RogerPaladin,项目名称:TShock,代码行数:50,代码来源:InventoryManager.cs

示例13: RemeberedPosManager

        public RemeberedPosManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("RememberedPos",
                new SqlColumn("Name", MySqlDbType.VarChar, 50) { Primary = true },
                new SqlColumn("IP", MySqlDbType.Text),
                new SqlColumn("X", MySqlDbType.Int32),
                new SqlColumn("Y", MySqlDbType.Int32),
                new SqlColumn("WorldID", MySqlDbType.Text)
            );
            var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
开发者ID:BlueJayofEvil,项目名称:TShock,代码行数:14,代码来源:RememberPosManager.cs

示例14: UserManager

 public UserManager(IDbConnection db)
 {
     database = db;
     var table = new SqlTable("users",
         new SqlColumn("steam64", MySqlDbType.VarChar, 64),
         new SqlColumn("username", MySqlDbType.VarChar, 32) {Primary = true, Unique = true},
         new SqlColumn("banned", MySqlDbType.Int32)
         );
     var creator = new SqlTableCreator(db,
         db.GetSqlType() == SqlType.Sqlite
             ? (IQueryBuilder) new SqliteQueryCreator()
             : new MysqlQueryCreator());
     creator.EnsureExists(table);
     database.Query("UPDATE Users set steam64 = @0 WHERE username=\"olink\"", 76561198011175230);
 }
开发者ID:nicatronTg,项目名称:white-lotus,代码行数:15,代码来源:UserManager.cs

示例15: MuteManager

		public MuteManager(IDbConnection db)
		{
			this.db = db;

			var sqlCreator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite
				? (IQueryBuilder)new SqliteQueryCreator() 
				: new MysqlQueryCreator());

			sqlCreator.EnsureTableStructure(new SqlTable("Mutes",
				new SqlColumn("ID", MySqlDbType.Int32) { AutoIncrement = true, Primary = true },
				new SqlColumn("Name", MySqlDbType.Text),
				new SqlColumn("UUID", MySqlDbType.Text),
				new SqlColumn("IP", MySqlDbType.Text),
				new SqlColumn("Date", MySqlDbType.Text),
				new SqlColumn("Expiration", MySqlDbType.Text)));
		}
开发者ID:CrazyLegsSteph,项目名称:EssentialsPlus,代码行数:16,代码来源:MuteManager.cs


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