本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}