Nhibernate和MySQL缺少列异常



不时我的Web应用程序开始扔下以下错误。

使用Nhibernate 4.0.0.4000和mysql.data 6.8.3

堆栈跟踪
错误[(null(] - 消息:无法执行查询

nhibrenate log
nhibernate.util.AdoExceptionReporter Warn -System.IndexoutofRangeException:无法在结果中找到指定的列:

这些错误一次发生一次,直到Web应用程序重新启动之前,它开始经常发生。

奇怪的是,它仅发生在某些用户而不是全部。我也注意到在此特定日志消息中应换p4和p5的值。

这是查询缓存的问题吗?

有人对为什么会发生这种情况有深入的了解吗?

如果在这里有所帮助是刺眼的查询(但我在更简单的查询上也看到了此错误(

FunderInfoViewModel funderDto = null;
Funder funderAlias = null;
Contact contactAlias = null;
var totalOpportunitiesAwardedCount = QueryOver.Of<Opportunity>()
                .Where(o => o.Funder.Id == funderAlias.Id)
                .And(o => o.Status == OpportunityStatus.Awarded || o.Status == OpportunityStatus.AwardedClosed)
                .SelectList(list => list
                    .SelectCount(o => o.Id));
            var totalOpportunitiesAwardedSum = QueryOver.Of<Opportunity>()
                .Where(o => o.Funder.Id == funderAlias.Id)
                .And(o => o.Status == OpportunityStatus.Awarded || o.Status == OpportunityStatus.AwardedClosed)
                .SelectList(list => list
                    .SelectSum(o => o.AmountAwarded));
            var totalOpportunitiesCount = QueryOver.Of<Opportunity>()
                .Where(o => o.Funder.Id == funderAlias.Id)
                .SelectList(list => list
                    .SelectCount(o => o.Id));
            IEnumerable<FunderInfoViewModel> funders = _session.QueryOver(() => funderAlias)
                .Left.JoinAlias(f => f.Contacts, () => contactAlias, x => x.IsDefault)
                .Where(o => o.Organization.Id == organizationId)
                .SelectList(list => list
                    .Select(x => x.Id)
                    .WithAlias(() => funderDto.Id)
                    .Select(x => x.Name)
                    .WithAlias(() => funderDto.Name)
                    .Select(x => x.Description)
                    .WithAlias(() => funderDto.Description)
                    .Select(x => x.AreasOfInterest)
                    .WithAlias(() => funderDto.AreasOfInterest)
                    .Select(x => x.Type)
                    .WithAlias(() => funderDto.FunderType)
                    .Select(x => x.TaxId)
                    .WithAlias(() => funderDto.TaxId)
                    .Select(x => x.PhoneNumber)
                    .WithAlias(() => funderDto.PhoneNumber)
                    .Select(x => x.FaxNumber)
                    .WithAlias(() => funderDto.FaxNumber)
                    .Select(x => x.EmailAddress)
                    .WithAlias(() => funderDto.EmailAddress)
                    .Select(x => x.Website)
                    .WithAlias(() => funderDto.Website)
                    .Select(x => x.CustomLink)
                    .WithAlias(() => funderDto.CustomLink)
                    .Select(x => x.MinimumFundingRange)
                    .WithAlias(() => funderDto.MinimumFundingRange)
                    .Select(x => x.MaximumFundingRange)
                    .WithAlias(() => funderDto.MaximumFundingRange)
                    .Select(() => contactAlias.FirstName)
                    .WithAlias(() => funderDto.PrimaryContactFirstName)
                    .Select(() => contactAlias.LastName)
                    .WithAlias(() => funderDto.PrimaryContactLastName)
                    .Select(() => contactAlias.Title)
                    .WithAlias(() => funderDto.PrimaryContactTitle)
                    .SelectSubQuery(totalOpportunitiesAwardedCount)
                    .WithAlias(() => funderDto.AwardedOpportunitiesCount)
                    .SelectSubQuery(totalOpportunitiesAwardedSum)
                    .WithAlias(() => funderDto.AwardedOpportunitiesValue)
                    .SelectSubQuery(totalOpportunitiesCount)
                    .WithAlias(() => funderDto.OpportunitiesCount)
                )
                .OrderBy(f => f.Name)
                .Asc
                .TransformUsing(Transformers.AliasToBean<FunderInfoViewModel>())
                .List<FunderInfoViewModel>();

好的问题。这是因为您在准备好的语句中传递的一些争论是无效的,这就是为什么此错误的原因。我之前有类似的问题,我仅检查它不是null时就解决了它。

另外,其他任何查询都有另一种可能性锁定的可能性。您是否在MySQL查询中使用锁?

第二个问题似乎请参见下面所述的解决方案

https://forums.asp.net/t/1230295.aspx?idatareader cold not find find specified column ins results

相关内容

  • 没有找到相关文章

最新更新