語法
Table.View(table as nullable table, handlers as record) as table
關於
傳回 table 的檢視,其中 handlers 中指定的函式可用來在將作業套用至檢視時取代預設作業行為。
如果提供 table,則所有處理常式函式都是選擇性的。 如果未提供 table,則需要 GetType 和 GetRows 處理常式函式。 若沒有針對作業指定處理常式函式,就會改為將預設作業行為套用至 table (但在 GetExpression 的情況下除外)。
處理器函式必須傳回一個在語意上等同於對 table 套用操作結果的值(若為 GetExpression,則為所產生的檢視)。
若處理常式函式引發錯誤,系統就會將預設作業行為套用至檢視。
Table.View 可用來實作折疊至數據源—將 M 查詢轉譯成來源特定查詢(例如,從 M 查詢建立 T-SQL 語句)。
範例 1
建立不需要存取資料列的基本檢視,以判斷類型或資料列計數。
使用方式
Table.View(
null,
[
GetType = () => type table [CustomerID = number, Name = text, Phone = nullable text],
GetRows = () => Table.FromRecords({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
GetRowCount = () => 1
]
)
輸出
Table.FromRecords({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]})