This is my query code, derived from the 2.0 Beta C# guide:
using (var query = QueryBuilder.Select(SelectResult.All())
.From(DataSource.Database(CouchServices.DbRecplication))
//.Where(
// Expression.Property("type").EqualTo(Expression.String("Address")))
//.OrderBy(Ordering.Property("type").Ascending(), Ordering.Property("name").Ascending()) // possibly need type here so we can use the TypeNameIndex
)
{
var rows = query.Execute();
foreach (var row in rows)
{
string s= row.GetString(0); // <-- won't get anything here, just 'null', but there must be a result as rows is being iterated through
...
}
}
Here is how I added an index and filled the database before:
CouchServices.DbRecplication.CreateIndex("TypeNameIndex", IndexBuilder.ValueIndex(
ValueIndexItem.Expression(Expression.Property("type")),
ValueIndexItem.Expression(Expression.Property("name"))));
Guid id1 = Guid.NewGuid();
var adr1 = new Address()
{
ID = id1.ToString(),
Name1 = "John Doe",
Name2 = "",
Name3 = "",
...
}
var newTest1doc = new MutableDocument(id1.ToString());
newTest1doc.SetString("type", adr1.GetType().FullName);
newTest1doc.SetString("name", adr1.Name1 + "/" + adr1.Name2 + "/" + adr1.Name3);
newTest1doc.SetDate("createdAt", DateTimeOffset.UtcNow);
newTest1doc.SetString("data", JsonConvert.SerializeObject(adr1));
CouchServices.DbRecplication.Save(newTest1doc);
var test1readdoc = CouchServices.DbRecplication.GetDocument(id1.ToString());
string json = test1readdoc.GetString("data"); // <-- this actually works
Where am I wrong here?