0

Foolowing MS Docs here:

https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-index-how-to?tabs=net

Some examples are given for queries:

// Blob index queries and selection
String singleEqualityQuery = @"""Archive"" = 'false'";
String andQuery = @"""Archive"" = 'false' AND ""Priority"" = '01'";
String rangeQuery = @"""Date"" >= '2020-04-20' AND ""Date"" <= '2020-04-30'";
String containerScopedQuery = @"@container = 'mycontainer' AND ""Archive"" = 'false'";

These examples are useless as no one in the real world is going to hard code queries using static values.

If i try to insert a variable into a query when using the 'AND' staement then the string won't compile. Example:

var varibale1 = "test1";
var varibale2 = "test2";
// Not working!
query = @"""folderDepth"" = '" + varibale1 + "' AND ""parentFolder"" = 'hardCodedvalue'";
// Hard coded values
query = @"""folderDepth"" = 'test1' AND ""parentFolder"" = 'test2'";

enter image description here

1

1 Answer 1

1

The screenshot below shows the MS code example I was trying to work with:

enter image description here

Each index tag in the above example queries are wrapped in two sets of double quotes. This would work until I started inserting variables into the query as shown below:

enter image description here

The query that worked for me was to escape the second index tag in the string i.e. ParentFolder.

// -----------------------------
// ----- Tested and worked -----
// -----------------------------
string query4 = @"""FolderDepth"" = '" + varibale1 + "' AND \"ParentFolder\" = '" + varibale2 + "'";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.