Ticket Q471259
Visible to All Users

Session.Evaluate problems

created 12 years ago

Hi all!!! I have department and contact classes! Every contact has appropriate department_number. I want to add number of my new contact from MAX + 1. And I try to do this:

C#
private Int32 _MaxRate; public Int32 MaxRate { get { try { _MaxRate = (Int32)Session.Evaluate<Contact>(new AggregateOperand("", "Number", Aggregate.Max), CriteriaOperator.Parse("Department.NumberOfDepartment = 'this.NumberOfdepartment'")); } catch (Exception) { } return _MaxRate; }

}

I want to fined MAX number of my contact from current department! First it mast filter by department and then fined MAX from current! But my code working wrong! Where I have mistake?

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hello Sergey,
The problem occurs because of the "'this.NumberOfdepartment'" parameter. The Evaluate method cannot process such parameters. Instead of this, pass the value of the NumberOfdepartment property to the criteria operator, as shown below:

C#
object result = Session.Evaluate<Contact>(new AggregateOperand("", "Number", Aggregate.Max), CriteriaOperator.Parse("Department.NumberOfDepartment = ?", this.NumberOfdepartment)); if (result != null) { return (Int32)result; } else { return 0; }
    Comments (2)
    SA SA
    Sergey Aleksandrov 12 years ago

      Thanks!!!

      Anatol (DevExpress) 12 years ago

        You are welcome!

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.