0

コードで次のHQLを使用しています

string sPastDueForCustomer = @"select 
    inv.fInvoiceDate as fInvoiceDate,
    cust.fName as fCustomerName,
    inv.fInvoiceNumberDisplay as fInvoiceNumberDisplay,
    inv.fBalance as fBalance,   
    inv.fDueDate as fDueDate,
    datediff(day, :GenerateDate, inv.fDueDate) as fDaysPastDue
    FROM tARInvoice as inv INNER JOIN inv.Customer as cust
    Where inv.fDueDate < :GenerateDate - " 
    + 
    ARApplicationSetup[0].fGracePeriod 
    + 
    @"  
    And inv.fInvoiceType= 'Manual'  
    And inv.fCustomerID = :CustomerID  
    And inv.fBalance > 0  
    And inv.fIsPosted = 1  
    And inv.fIsVoided = 0";                

    //get the result of query and return the object of PaymentInvoiceDetails
    IList<tARInvoice> PastDueForCustomer = 
        Session.CreateQuery(sPastDueForCustomer)
               .SetGuid("CustomerID", CustomerId)
               .SetDateTime("GenerateDate", GenerateDate)
               .SetResultTransformer(Transformers.AliasToBean<tARInvoice())
               .List<tARInvoice>();

これを実行すると、次のエラーが発生します。

No data type for node: 
MethodNode (datediff(exprList day ? (tarinvoice0_.fDueDate tarinvoice0_.fARInvoiceID fDueDate)))
[select
    inv.fInvoiceDate as fInvoiceDate,
    cust.fName as fCustomerName,
    inv.fInvoiceNumberDisplay as fInvoiceNumberDisplay,
    inv.fBalance as fBalance,   
    inv.fDueDate as fDueDate
    ,datediff(day, :GenerateDate,inv.fDueDate) as fDaysPastDue 
    FROM tARInvoice as inv INNER JOIN inv.Customer as cust
    Where inv.fDueDate < :GenerateDate - 15  
    And inv.fInvoiceType= 'Manual'  
    And inv.fCustomerID = :CustomerID  
    And inv.fBalance > 0  
    And inv.fIsPosted = 1  
    And inv.fIsVoided = 0]

の型はfDaysPastDueですint

4

1 に答える 1

0

ここに、

WHERE inv.fDueDate < :GenerateDate - " + ARApplicationSetup[0].fGracePeriod + @" ... 

inta からan を減算するとDateTime、次のようになります。

WHERE inv.fDueDate < :GenerateDate - 15

操作にさまざまなタイプが含まれるため、エラーが発生します。

GenerateDate変数から正しい型を使用していることを確認し、クエリで正しく設定してください。

Session.CreateQuery(sPastDueForCustomer)
       .SetGuid("CustomerID", CustomerId)
       .SetInt32("GenerateDate", GenerateDate.Days) 
       // instead of: ".SetDateTime(GenerateDate)"
       ...
于 2013-01-18T15:10:06.937 に答える