基本的に、データベースからのデータを使用してレポートを生成しようとしています。ただし、レポートを生成するたびに、次の例外が発生します。
タイプ「HealthCardLabelPrinter.Entities.CardProcessed」の変数「x」がスコープ「」から参照されていますが、定義されていません
例外をスローする私のコードは次のとおりです。
public BindingList<CardProcessed> GetByLocationAndDate(string location_id, string sdate, string edate)
{
var fromDb = session.QueryOver<CardProcessed>()
.Where(x => (DateTime.Parse(x.draw_date) >= DateTime.Parse(sdate)))
.And(x => DateTime.Parse(x.draw_date) <= DateTime.Parse(edate))
.JoinQueryOver(m => m._location)
.Where(m => m.location_id == location_id)
.List<CardProcessed>();
var newList = new BindingList<CardProcessed>();
foreach (var record in fromDb)
{
newList.Add(record);
}
return newList;
}
2 つのクラス マップ:
public LocationMap()
{
Id(x => x.LocationId).Column("locationId").GeneratedBy.Identity();
Map(x => x.name)
.Not.Nullable();
Map(x => x.location_id)
.Not.Nullable();
HasMany(x => x.records)
.KeyColumns
.Add("cardProcessedId")
.ForeignKeyConstraintName("none");
}
public CardProcessedMap()
{
Id(x => x.CardProcessedId).Column("cardProcessedId").GeneratedBy.Identity();
References<hcData>(x => x._hcData, "dataId").ForeignKey("none");
References<User>(x => x._user, "userId").ForeignKey("none");
References<Location>(x => x._location, "locationId").ForeignKey("none");
References<Doctor>(x => x._doctor, "doctorId").ForeignKey("none");
Map(x => x.label_amount_encrypted)
.Column("labelAmount");
Map(x => x.draw_date)
.Column("drawDate");
Map(x => x.fee_encrypted)
.Column("fee");
Map(x => x.phone_encrypted)
.Column("phone");
}
QueryOver の変数 'x' を定義する方法を教えてください。
エラーのスタックトレース:
at System.Linq.Expressions.Compiler.VariableBinder.Reference(ParameterExpression node, VariableStorageKind storage)
at System.Linq.Expressions.Compiler.VariableBinder.VisitParameter(ParameterExpression node)
at System.Linq.Expressions.ParameterExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitMember(MemberExpression node)
at System.Linq.Expressions.MemberExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)
at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection`1 nodes)
at System.Linq.Expressions.Compiler.VariableBinder.VisitLambda[T](Expression`1 node)
at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator)
at System.Linq.Expressions.LambdaExpression.Compile()
at NHibernate.Impl.ExpressionProcessor.FindValue(Expression expression)
at NHibernate.Impl.ExpressionProcessor.FindMemberProjection(Expression expression)
at NHibernate.Impl.ExpressionProcessor.ProcessSimpleExpression(Expression left, Expression right, ExpressionType nodeType)
at NHibernate.Impl.ExpressionProcessor.ProcessSimpleExpression(BinaryExpression be)
at NHibernate.Impl.ExpressionProcessor.ProcessBinaryExpression(BinaryExpression expression)
at NHibernate.Impl.ExpressionProcessor.ProcessExpression(Expression expression)
at NHibernate.Impl.ExpressionProcessor.ProcessLambdaExpression(LambdaExpression expression)
at NHibernate.Impl.ExpressionProcessor.ProcessExpression[T](Expression`1 expression)
at NHibernate.Criterion.QueryOver`2.Add(Expression`1 expression)
at NHibernate.Criterion.QueryOver`2.Where(Expression`1 expression)
at NHibernate.Criterion.QueryOver`2.NHibernate.IQueryOver<TRoot,TSubType>.Where(Expression`1 expression)
at HealthCardLabelPrinter.Repositories.CardProcessedRepository.GetAllByLocationAndDate(String location_id, String sdate, String edate) in c:\Users\Craig_2\Documents\Visual Studio 2012\Projects\HealthCardLabelPrinter\HealthCardLabelPrinter\Repositories\CardProcessedRepository.cs:line 52
at HealthCardLabelPrinter.Report.RenderReport(DateTime start, DateTime end, Location location, String fpath) in c:\Users\Craig_2\Documents\Visual Studio 2012\Projects\HealthCardLabelPrinter\HealthCardLabelPrinter\Report.cs:line 39
at HealthCardLabelPrinter.frmMain.frmMain_FormClosing(Object sender, FormClosingEventArgs e) in c:\Users\Craig_2\Documents\Visual Studio 2012\Projects\HealthCardLabelPrinter\HealthCardLabelPrinter\frmMain.cs:line 452
at System.Windows.Forms.Form.OnFormClosing(FormClosingEventArgs e)
at System.Windows.Forms.Form.CheckCloseDialog(Boolean closingOnly)