我在我的应用程序中使用 nhibernate 作为 orm 并使用 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;