Tôi phải thực hiện tìm kiếm để trả về một giá trị, tôi phải làm là tổng số nhân hai trường. Tôi có đoạn mã sau:Thực hiện phép nhân trong SQL
internal double TotalRes(long Id)
{
double total = 0;
Reserve rAlias = null;
var query = Session.QueryOver<Item>();
query = query.JoinAlias(e => e.Reserve,() => rAlias);
query = query.Where(() => rAlias.Id == Id);
query = query.Select(Projections.Sum<Item>(acct => acct.Ammount * acct.Wight));
object result = query.UnderlyingCriteria.UniqueResult();
if (result != null)
total = Convert.ToDouble(result);
return total;
}
Nó được đưa ra các lỗi sau:
the variable 'acct' type 'tem' is referenced in scope '', but it is not set
Làm thế nào tôi có thể quay trở lại giá trị này?
Có phải 'Chiếu' lớp học của bạn hay là một phần của nhibernate? (Không bao giờ sử dụng thư viện) –
bản sao có thể có của [Expression.Lambda: Biến 'x' của loại '' được tham chiếu từ phạm vi '', nhưng nó không được xác định] (http://stackoverflow.com/questions/9778749/expression- lambda-variable-x-of-type-tham chiếu-từ-phạm vi-nhưng-it-is-n) –
Một phần của nhibernate @ScottChamberlain –