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


C# IDatabase.QueryValue方法代码示例

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


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

示例1: VerifyUserNameHasConfirmedAccount

        // Ensures the user exists in the accounts table
        private int VerifyUserNameHasConfirmedAccount(IDatabase db, string username, bool throwException)
        {
            int userId = GetUserId(db, SafeUserTableName, SafeUserNameColumn, SafeUserIdColumn, username);
            if (userId == -1)
            {
                if (throwException)
                {
                    throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, WebDataResources.Security_NoUserFound, username));
                }
                else
                {
                    return -1;
                }
            }

            int result = db.QueryValue(@"SELECT COUNT(*) FROM " + MembershipTableName + " WHERE (UserId = @0 AND IsConfirmed = 1)", userId);
            if (result == 0)
            {
                if (throwException)
                {
                    throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, WebDataResources.Security_NoAccountFound, username));
                }
                else
                {
                    return -1;
                }
            }
            return userId;
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:30,代码来源:SimpleMembershipProvider.cs

示例2: GetPasswordFailuresSinceLastSuccess

 private static int GetPasswordFailuresSinceLastSuccess(IDatabase db, int userId)
 {
     var failure = db.QueryValue(@"SELECT PasswordFailuresSinceLastSuccess FROM " + MembershipTableName + " WHERE (UserId = @0)", userId);
     if (failure != null)
     {
         return failure;
     }
     return -1;
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:9,代码来源:SimpleMembershipProvider.cs

示例3: GetUserId

 internal static int GetUserId(IDatabase db, string userTableName, string userNameColumn, string userIdColumn, string userName)
 {
     var result = db.QueryValue(@"SELECT " + userIdColumn + " FROM " + userTableName + " WHERE (UPPER(" + userNameColumn + ") = @0)", userName.ToUpperInvariant());
     if (result != null)
     {
         return (int)result;
     }
     return -1;
 }
开发者ID:reza899,项目名称:aspnetwebstack,代码行数:9,代码来源:SimpleMembershipProvider.cs

示例4: GetUserId

 internal static int GetUserId(IDatabase db, string userTableName, string userNameColumn, string userIdColumn, string userName)
 {
     // Casing is normalized in Sql to allow the database to normalize username according to its collation. The common issue 
     // that can occur here is the 'Turkish i problem', where the uppercase of 'i' is not 'I' in Turkish.
     var result = db.QueryValue(@"SELECT " + userIdColumn + " FROM " + userTableName + " WHERE (UPPER(" + userNameColumn + ") = UPPER(@0))", userName);
     if (result != null)
     {
         return (int)result;
     }
     return -1;
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:11,代码来源:SimpleMembershipProvider.cs

示例5: GetUserId

        internal static int GetUserId(
            IDatabase db,
            string userTableName,
            string userNameColumn,
            string userIdColumn,
            SimpleMembershipProviderCasingBehavior casingBehavior,
            string userName)
        {
            dynamic result;
            if (casingBehavior == SimpleMembershipProviderCasingBehavior.NormalizeCasing)
            {
                // Casing is normalized in Sql to allow the database to normalize username according to its collation. The common issue 
                // that can occur here is the 'Turkish i problem', where the uppercase of 'i' is not 'I' in Turkish.
                result = db.QueryValue(@"SELECT " + userIdColumn + " FROM " + userTableName + " WHERE (UPPER(" + userNameColumn + ") = UPPER(@0))", userName);
            }
            else if (casingBehavior == SimpleMembershipProviderCasingBehavior.RelyOnDatabaseCollation)
            {
                // When this option is supplied we assume the database has been configured with an appropriate casing, and don't normalize 
                // the user name. This is performant but requires appropriate configuration on the database.
                result = db.QueryValue(@"SELECT " + userIdColumn + " FROM " + userTableName + " WHERE (" + userNameColumn + " = @0)", userName);
            }
            else
            {
                Debug.Fail("Unexpected enum value");
                return -1;
            }

            if (result != null)
            {
                return (int)result;
            }
            return -1;
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:33,代码来源:SimpleMembershipProvider.cs


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