Is it possible to select all properties in Query.Select() without specifying the Expression.Property in SelectResult.Expression in .NET? Similar how you can do it in SQL with * (star).
That didn’t make it into db013 but will be in db014
Thanks. The release notes mentioned that dbo13 only works with 1.5.0-477 or higher. Do you know where I can find this build?
The latest I can find is this 377 here https://www.couchbase.com/downloads/thankyou/community?product=sync-gateway&version=1.5.0&platform=windows&addon=false&prerelease=true
Thanks Again!
Sorry about our website right now…I don’t know what is going on. It seems like the data got sent way back in time when the layout update happened and it takes forever to get it corrected…but go to this page to get build 477 until that page is fixed.
FYI …Filed a bug with the web team to fix the downloads page.
@borrrden, Hello, I am @vgorokhovskiy’s coworker, I just wanted to mention that I updated to the latest nuget package, db018 and tried revisiting this issue using SelectResult.All()
from the API but it did not return the results I was expecting vs explicitly adding parameters.
for example when trying to extract a list of Branches I tried the following two queries:
var query = Query.Select(SelectResult.All())
.From(DataSource.Database(_dataAccessManager.GetDbContext()))
.Where(Expression.Property("doc_type").EqualTo("Branch"));
vs
var branchNumberExpression = Expression.Property("BranchNumber");
var branchNameExpression = Expression.Property("BranchName");
var teiOfficeIdExpression = Expression.Property("TeiOfficeID");
var ibsDatabaseNameExpression = Expression.Property("IbsDatabaseName");
var regionNameExpression = Expression.Property("RegionName");
var id = Expression.Property("_id");
var query = Query.Select(SelectResult.Expression(branchNumberExpression), SelectResult.Expression(id)
,SelectResult.Expression(branchNameExpression)
,SelectResult.Expression(teiOfficeIdExpression)
,SelectResult.Expression(ibsDatabaseNameExpression)
,SelectResult.Expression(regionNameExpression))
.From(DataSource.Database(_dataAccessManager.GetDbContext()))
.Where(Expression.Property("doc_type").EqualTo("Branch"));
with the same usage:
var rows = query.Run();
foreach (var row in rows)
{
branches.Add(new JsonBranch
{
BranchNumber = row.GetString("BranchNumber"),
BranchName = row.GetString("BranchName"),
TeiOfficeID = row.GetInt("TeiOfficeID"),
IbsDatabaseName = row.GetString("IbsDatabaseName"),
RegionName = row.GetString("RegionName")
});
}
Using the SelectResult.All()
parameter returns the correct number of rows, but the row.GetString()
calls all return null.
Explicitly calling each property by name allows row.GetString()
to return the value of the property correctly and gives me the objects that I want.
Am I misunderstanding the SelectResult.All()
functionality?
Thank you for your assistance!
You are slightly misunderstanding. In your second example notice that you are accessing each result at the top level. The All
item is also at the top level, but since it doesn’t have to be by itself (i.e. you could select all and something else in the same select e.g. Select(SelectResult.All(), SelectResult.Expression(branchNameExpression))
). Perhaps you see where this is going? It means that you will have one entry as a dictionary that you can get at index 0 (row.GetDictionary(0).GetString("BranchNumber"))
).
I see, that clears it up. I have added the GetDictionary(0)
call and it is working now! Thanks very much for your assistance.