私はアプリでormとしてnhibernateを使用し、データベースとしてfirebirdを使用しています。現在、メンバーシッププロバイダーを行使しようとしていますが、次のエラーメッセージが表示されます
The driver NHibernate.Driver.FirebirdClientDriver does not support multiple queries.
次のコードを持つ私のテストメソッド
#region Test FindUserByEmail
[Test]
public void FindUserByEmail()
{
//Arrange
var email = "jamesbond@mi6.uk";
var recs = -1;
var expectedRecords = 1;
//Act
var actual = _provider.FindUsersByEmail(email, 0, 99, out recs);
//Assert
Assert.AreEqual(expectedRecords, recs);
Assert.AreEqual(expectedRecords, actual.Count);
}
#endregion
nhibernate firebirdドライバーが複数のクエリを受け入れるソリューションはありますか?
追加されたFindUsersByEmailメソッドを更新します
public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
{
CheckParameter(ref emailToMatch, false, false, false, 100, "emailToMatch");
if (pageIndex < 0)
{
throw new ArgumentException("The pageIndex must be greater than or equal to zero.", "PageIndex");
}
if (pageSize < 1)
{
throw new ArgumentException("The pageSize must be greater than zero.", "pageSize");
}
long upperBound = (long)pageIndex * pageSize + pageSize - 1;
if (upperBound > Int32.MaxValue)
{
throw new ArgumentException("The combination of pageIndex and pageSize cannot exceed the maximum value of System.Int32.", "pageIndex and pageSize");
}
totalRecords = 0;
MembershipUserCollection users = new MembershipUserCollection();
IList results;
using (ISession session = SessionProvider.Instance.OpenSession())
{
using (ITransaction tran = session.BeginTransaction())
{
results = session.CreateMultiCriteria()
.Add(session.CreateCriteria(typeof(User)).Add(Restrictions.Like("UpperEmail", emailToMatch.ToUpper())).SetFirstResult(pageIndex * pageSize).SetMaxResults(pageSize))
.Add(session.CreateCriteria(typeof(User)).Add(Restrictions.Like("UpperEmail", emailToMatch.ToUpper())).SetProjection(Projections.RowCountInt64()))
.List();
tran.Commit();
}
}
var dbUsers = (List<User>)results[0];
totalRecords = (int)results[1];
foreach (User u in dbUsers)
{
users.Add(new MembershipUser(Name,
u.UserName,
u.Id,
u.EMail,
u.PasswordQuestion,
u.Comment,
u.IsApproved,
u.IsLockedOut,
u.CreationDate,
GetNullableDateTime(u.LastLoginDate),
GetNullableDateTime(u.LastActivityDate),
GetNullableDateTime(u.LastPasswordChangeDate),
GetNullableDateTime(u.LastLockedOutDate)));
}
return users;