기본적으로 데이터베이스의 데이터로 보고서를 생성하려고합니다. 여기에 예외가 발생QueryOver를 잘못 사용하고 있습니까?
variable 'x' of type 'HealthCardLabelPrinter.Entities.CardProcessed' referenced from scope '', but it is not defined
내 코드입니다 : 내가 보고서를 생성하지만 매번는,이 예외가
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;
}
두 클래스 맵 :
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)
을, 당신의 간결한 설명을 주셔서 감사합니다 . – Craig