我有一个名为add_action( 'wp_ajax_my_action', 'my_action_callback' );
add_action( 'wp_ajax_nopriv_my_action', 'my_action_callback' );
function my_action_callback() {
global $wpdb; // this is how you get access to the database
$whatever = intval( $_POST['whatever'] );
$whatever += 10;
echo $whatever;
wp_die(); // this is required to terminate immediately and return a proper response
}
的集合,每个条目都有一个名为Customer
的属性。以下是select all命令的内容:
Number
我使用Azure门户针对此集合触发以下查询:
[
{
"Number": "K1",
"Label": "Test1"
},
{
"Number": "T1",
"Label": "Test2"
}
]
这给了我正确的结果:
SELECT * FROM c WHERE STARTSWITH(c.Number, 'K')
但是当我使用DocumentDB NuGet包在C#中执行此操作时:
[
{
"Number": "K1",
"Label": "Test1"
}
]
然后每次都会检索所有(在这种情况下为2)项目。
似乎var options = new FeedOptions();
var query = "SELECT * FROM c WHERE STARTSWITH(c.Number, 'K')";
var items = client.CreateDocumentQuery<Customer>(uri, options, query).ToList()
完全忽略了这句话。
修改
查询的ActivityId为CreateDocumentQuery
。
答案 0 :(得分:1)
查看CreateDocumentQuery
的定义,其参数为uri
,query
,options
...,如果您放置选项而不是查询,则会默认查询为null,因此您只获得集合中的所有项目。
public IQueryable<T> CreateDocumentQuery<T>(Uri documentCollectionOrDatabaseUri, SqlQuerySpec querySpec, FeedOptions feedOptions = null, object partitionKey = null);
将其更改为:
var items = client.CreateDocumentQuery<Customer>(uri, query, options).ToList()