-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
40 lines (38 loc) · 1.4 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Diagnostics;
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
using DevExpress.Xpo.DB;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Quote q = Session.DefaultSession.FindObject<Quote>(new OperandProperty("Oid") == 1) as Quote;
if (q == null) {
q = new Quote();
for (int i = 0; i < 5; i++) {
QuoteItem qi = new QuoteItem();
qi.Sequence = i;
q.QuoteItems.Add(qi);
qi.Save();
}
q.Save();
}
int maxValue = Convert.ToInt32(
Session.DefaultSession.Evaluate<QuoteItem>(
CriteriaOperator.Parse("Max(Sequence)"),
new OperandProperty("Quote.Oid") == q.Oid
)
);
Debug.Assert(maxValue == 4, "Error");
XPCollection<QuoteItem> items = new XPCollection<QuoteItem>(
new OperandProperty("Quote.Oid") == q.Oid,
new SortProperty("Sequence", SortingDirection.Descending)
);
items.TopReturnedObjects = 1;
if (items.Count != 0) {
QuoteItem maxQuoteItemObject = items[0] as QuoteItem;
Debug.Assert(maxQuoteItemObject.Sequence == 4, "Error");
}
}
}
}