pack()pack()

从名称和值的列表创建一个 dynamic 对象(属性包)。Creates a dynamic object (property bag) from a list of names and values.

pack_dictionary() 函数的别名。Alias to pack_dictionary() function.

语法Syntax

pack(key1, value1, key2, value2,... )pack(key1, value1, key2, value2,... )

参数Arguments

  • 键和值的交替列表(列表的总长度必须为偶数)An alternating list of keys and values (the total length of the list must be even)
  • 所有键都必须为非空常量字符串All keys must be non-empty constant strings

示例Examples

以下示例返回 {"Level":"Information","ProcessID":1234,"Data":{"url":"www.bing.com"}}The following example returns {"Level":"Information","ProcessID":1234,"Data":{"url":"www.bing.com"}}:

pack("Level", "Information", "ProcessID", 1234, "Data", pack("url", "www.bing.com"))

让我们看看 2 个表:SmsMessages 和 MmsMessages:Lets take 2 tables, SmsMessages and MmsMessages:

表 SmsMessagesTable SmsMessages

SourceNumberSourceNumber TargetNumberTargetNumber CharsCountCharsCount
555-555-1234555-555-1234 555-555-1212555-555-1212 4646
555-555-1234555-555-1234 555-555-1213555-555-1213 5050
555-555-1212555-555-1212 555-555-1234555-555-1234 3232

表 MmsMessagesTable MmsMessages

SourceNumberSourceNumber TargetNumberTargetNumber AttachmentSizeAttachmentSize AttachmentTypeAttachmentType AttachmentNameAttachmentName
555-555-1212555-555-1212 555-555-1213555-555-1213 200200 jpegjpeg Pic1Pic1
555-555-1234555-555-1234 555-555-1212555-555-1212 250250 jpegjpeg Pic2Pic2
555-555-1234555-555-1234 555-555-1213555-555-1213 300300 pngpng Pic3Pic3

以下查询:The following query:

SmsMessages 
| extend Packed=pack("CharsCount", CharsCount) 
| union withsource=TableName kind=inner 
( MmsMessages 
  | extend Packed=pack("AttachmentSize", AttachmentSize, "AttachmentType", AttachmentType, "AttachmentName", AttachmentName))
| where SourceNumber == "555-555-1234"

返回:Returns:

TableNameTableName SourceNumberSourceNumber TargetNumberTargetNumber PackedPacked
SmsMessagesSmsMessages 555-555-1234555-555-1234 555-555-1212555-555-1212 {"CharsCount":46}{"CharsCount": 46}
SmsMessagesSmsMessages 555-555-1234555-555-1234 555-555-1213555-555-1213 {"CharsCount":50}{"CharsCount": 50}
MmsMessagesMmsMessages 555-555-1234555-555-1234 555-555-1212555-555-1212 {"AttachmentSize":250, "AttachmentType": "jpeg", "AttachmentName":"Pic2"}{"AttachmentSize": 250, "AttachmentType": "jpeg", "AttachmentName": "Pic2"}
MmsMessagesMmsMessages 555-555-1234555-555-1234 555-555-1213555-555-1213 {"AttachmentSize":300, "AttachmentType": "png", "AttachmentName":"Pic3"}{"AttachmentSize": 300, "AttachmentType": "png", "AttachmentName": "Pic3"}