是否可以使用xpoDataSource从表值函数中进行选择,而不是从表中进行选择。
注意:我使用xpoDatasource和serverMode = true
答案 0 :(得分:1)
来源 - Table Valued Function in XPO (and XAF)?
您可以通过直接SQL查询完成此任务。这是一个例子:
IDataLayer dal = XpoDefault.GetDataLayer(MSSqlConnectionProvider.GetConnectionString("(local)", "TestDatabase"), AutoCreateOption.None);
Session session = new Session(dal);
SelectedData data = session.ExecuteQueryWithMetadata("SELECT * FROM TrackingItemsModified(2)");
XPDataView view = new XPDataView();
foreach (var row in data.ResultSet[0].Rows) {
view.AddProperty((string)row.Values[0], DBColumn.GetType((DBColumnType)Enum.Parse(typeof(DBColumnType), (string)row.Values[2])));
}
view.LoadData(new SelectedData(data.ResultSet[1]));
GridControl control = new GridControl();
control.DataSource = view;
control.Dock = DockStyle.Fill;
Form form = new Form();
form.Controls.Add(control);
form.ShowDialog();
参考这些:
How to populate an XPServerCollectionSource/InstantFeedbackCollectionSource with a runtime designed SQL statement result?
How to pass a table valued parameter to Session.ExecuteSProc method