DevExpress WinForms能完美構建流暢、美觀且易於使用的應用程序,無論是Office風格的界面,還是分析處理大批量的業務數據,它都能輕鬆勝任!
先決條件
平台:
- Frameworks (XAF & XPO)
- WinForms
產品:
- eXpress Persistent Objects
這些新的只讀服務器模式組件是
XPServerCollectionSource/XPInstantFeedbackSource和XPView 的混合,可與DevExpress Grid控件一起使用。
它們提供以下內容:
- 能以較低的內存使用量處理大型數據源(不會加載整個持久對象實例)。
- 能自定義SELECT語句並排除未使用的數據列。
- 能在根查詢中包括引用屬性數據,以避免1 + N問題。
- 能包含使用ServerViewProperty在服務器端計算的自定義(虛擬)屬性。
在將這些組件用作網格的數據源之前,請按以下方式配置它們:
1. 在代碼或組件設計器中設置ObjectType和Properties,ServerViewProperty支持表達式中的持久性或別名屬性。
C#
xpServerModeView1.ObjectType = typeof(Order);
xpInstantFeedbackView1.ObjectType = typeof(Order);
var viewProperties = new ServerViewProperty[] {
new ServerViewProperty("Oid", SortDirection.Ascending, "[Oid]"),
new ServerViewProperty("OrderDate", SortDirection.None, "[OrderDate]"),
new ServerViewProperty("Customer", SortDirection.None, "[Customer.ContactName]"),
new ServerViewProperty("ProductName", SortDirection.None, "[ProductName]"),
new ServerViewProperty("Price", SortDirection.None, "[Price]"),
new ServerViewProperty("Quantity", SortDirection.None, "[Quantity]"),
new ServerViewProperty("TotalPrice", SortDirection.None, "[Quantity] * [Price]"),
new ServerViewProperty("Tax", SortDirection.None, "[Quantity] * [Price] * 0.13")
};
xpServerModeView1.Properties.AddRange(viewProperties);
xpInstantFeedbackView1.Properties.AddRange(viewProperties);2. 處理ResolveSession事件來提供一個Session,以從數據存儲中檢索對象。
C#
session = new Session(XpoDefault.DataLayer);
xpServerModeView1.ResolveSession += (s, e) => {
e.Session = session;
};
xpInstantFeedbackView1.ResolveSession += (s, e) => {
e.Session = session;
};3. 對於XPInstantFeedbackView,可以選擇處理DismissSession事件以手動處理在ResolveSession事件處理程序中創建的Session。
C#
xpInstantFeedbackView1.DismissSession += (s, e) => {
IDisposable session = e.Session as IDisposable;
if (session != null) {
session.Dispose();
}
};原創文章,作者:投稿專員,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/225718.html
微信掃一掃
支付寶掃一掃