XPODataSource:Select 来自 TableValuedFunctions

XPODataSource: Select from TableValuedFunctions

是否可以使用 xpoDataSource 从 tabled 值函数中 select 而不是从 table 中 selecting。

注意:我正在使用 xpoDatasource with serverMode = true

来源 - 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