Skip to content

Commit 2d836f0

Browse files
authored
saDOC-8272-C4-Net -- C# N1QL Code Snippets (#531)
* DOC-8272-C4-Net -- C# N1QL Code Snippets https://issues.couchbase.com/browse/DOC-8272 * DOC-8272-C4-Net -- C# N1QL Code Snippets Fedback https://issues.couchbase.com/browse/DOC-8272
1 parent a756713 commit 2d836f0

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

modules/csharp/examples/code_snippets/Program.cs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,40 +1670,48 @@ public Document Resolve(Conflict conflict)
16701670
}
16711671
}
16721672
// end::merge-conflict-resolver[]
1673-
1673+
}
16741674

16751675
// N1QL QUERY
16761676

1677-
1678-
public List<Result> testN1QLQueryString (Database argDB)
1677+
public List<Result> docsonly_N1QLQueryString(Database argDB)
16791678
{
1680-
// For Documentation
16811679
DatabaseConfiguration dbCfg = new DatabaseConfiguration();
1682-
dbCfg.Directory =
1683-
Path.Combine(Service.GetInstance<IDefaultDirectoryResolver>().DefaultDirectory(), username);
1684-
// tag::query-syntax-n1ql[]
1680+
16851681
Database thisDb = new Database(dbName, dbCfg);
16861682

1683+
// For Documentation -- N1QL Query
1684+
// tag::query-syntax-n1ql[]
16871685
var thisQuery =
1688-
thisDb.CreateQuery(
1689-
"SELECT META().id AS thisId FROM $thisDb.name " +
1690-
"WHERE type = $type"); // <.>
1691-
1692-
thisQuery.Parameters.SetString("type", "hotel"); // <.>
1686+
thisDb.CreateQuery("SELECT META().id AS thisId FROM _ WHERE type = \"hotel\""); // <.>
16931687

1694-
var results = thisQuery.Execute().AllResults();
1688+
return thisQuery.Execute().AllResults();
16951689

1696-
return results;
16971690
// end::query-syntax-n1ql[]
16981691
}
16991692

1700-
// tag::query-syntax-n1ql-params[]
1701-
tbd
1702-
// end::query-syntax-n1ql-params[]
17031693

1704-
// tag::query-access-n1ql[]
1705-
tbd
1706-
// end::query-access-n1ql[]
1694+
public List<Result> docsonly_N1QLQueryStringParams(Database argDB)
1695+
{
1696+
DatabaseConfiguration dbCfg = new DatabaseConfiguration();
1697+
1698+
Database thisDb = new Database(dbName, dbCfg);
1699+
1700+
// For Documentation -- N1QL Query
1701+
// tag::query-syntax-n1ql-params[]
1702+
// Declared elsewhere: Database argDB
1703+
1704+
var thisQuery =
1705+
thisDb.CreateQuery("SELECT META().id AS thisId FROM _ WHERE type = $type"); // <.>
1706+
1707+
var n1qlParams = new Parameters();
1708+
n1qlParams.SetString("type", "hotel"); // <.>
1709+
thisQuery.Parameters = n1qlParams;
1710+
1711+
return thisQuery.Execute().AllResults();
1712+
1713+
// end::query-syntax-n1ql-params[]
1714+
}
17071715

17081716

17091717
// QUERY RESULT SET HANDLING EXAMPLES

0 commit comments

Comments
 (0)