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


C# SqlDatabaseClient.ExecuteScalar方法代码示例

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


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

示例1: CreatePet

        public static Pet CreatePet(SqlDatabaseClient MySqlClient, uint UserId, int Type, string Name, int Race)
        {
            MySqlClient.SetParameter("userid", UserId);
            MySqlClient.SetParameter("type", Type);
            MySqlClient.SetParameter("name", Name);
            MySqlClient.SetParameter("race", Race);
            MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent());

            string RawId = MySqlClient.ExecuteScalar("INSERT INTO pets (user_id,type,name,race,timestamp) VALUES (@userid,@type,@name,@race,@timestamp); SELECT LAST_INSERT_ID();").ToString();

            uint Id = 0;
            uint.TryParse(RawId, out Id);

            if (Id == 0)
            {
                return null;
            }

            return new Pet(Id, Name, Type, Race, UserId, 0, new Vector3(0, 0, 0), UnixTimestamp.GetCurrent(), 0, 120, 100, 0);
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:20,代码来源:PetFactory.cs

示例2: CreateItem

        public static Item CreateItem(SqlDatabaseClient MySqlClient, uint DefinitionId, uint UserId, string Flags, string FlagsDisplay, double ExpireTimestamp, bool Untradable = false)
        {
            MySqlClient.SetParameter("definitionid", DefinitionId);
            MySqlClient.SetParameter("userid", UserId);
            MySqlClient.SetParameter("flags", Flags);
            MySqlClient.SetParameter("flagsd", FlagsDisplay);
            MySqlClient.SetParameter("untradable", Untradable ? "1" : "0");
            MySqlClient.SetParameter("expiretimestamp", ExpireTimestamp);

            string RawId = MySqlClient.ExecuteScalar("INSERT INTO items (definition_id,user_id,flags,flags_display,untradable,expire_timestamp) VALUES (@definitionid,@userid,@flags,@flagsd,@untradable,@expiretimestamp); SELECT LAST_INSERT_ID();").ToString();

            uint Id = 0;
            uint.TryParse(RawId, out Id);

            if (Id == 0)
            {
                return null;
            }

            return new Item(Id, DefinitionId, UserId, 0, new Vector3(), string.Empty, 0, Flags, Flags, Untradable, 0, 0,
                ExpireTimestamp);
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:22,代码来源:ItemFactory.cs

示例3: FillCache

        public static void FillCache(SqlDatabaseClient MySqlClient, uint LinkedItemId)
        {
            if (mCache.ContainsKey(LinkedItemId))
            {
                mCache.Remove(LinkedItemId);
            }

            uint IdValue = 0;

            MySqlClient.SetParameter("id", LinkedItemId);
            object Result = MySqlClient.ExecuteScalar("SELECT room_id FROM items WHERE id = @id LIMIT 1");

            if (Result != null)
            {
                IdValue = (uint)Result;
            }

            if (IdValue > 0)
            {
                mCache.Add(LinkedItemId, IdValue);
            }
        }
开发者ID:habb0,项目名称:Snowlight,代码行数:22,代码来源:TeleporterLinkFinder.cs


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